sql - How to fetch dynamic table list in MVC and angularJS -


i'm getting list in angular.js file (editdeleteitem.js) i'm making based on selected table name.

the function send list below:-

$scope.savetblrecord = function (list) {         //alert(json.stringify($scope.employeelist));          $scope.fetchtablename();         //var data = $.param({ tbldata: $scope.mytbldatalist });         var itemlist = [];         angular.foreach(list, function (value, key) {             if (list[key].selected) {                 itemlist.push(list[key].selected);             }         });          $scope.itemslist = [];         $scope.itemslist = itemlist;          $http({             method: "post",             url: "/admin/savetbldata",             data: $scope.itemslist,         }).success(function (data) {             $scope.gettbldata($scope.tempname);         }).error(function (err) {             alert(err.message);         })     };//savetblrecord 

now in controller want fetch list based on selected table name can't :-

public jsonresult savetbldata(list<locationtbl> newtbllist)    //need have tablename here instead of locationtbl selected table name list fetched.     {          string mytablename = convert.tostring(tempdata["tablename"]);          try         {             if (newtbllist == null)             {                 return new jsonresult { data = "empty selection", jsonrequestbehavior = jsonrequestbehavior.allowget };             }             else {                 using (ebcontext db = new ebcontext())                 {                     bool results = false;                      type tabletype = typeof(coursedesc);                     switch (mytablename)                     {                         //case "coursetbl":                         //    (int = 0; < newtbllist.count; i++)                         //    {                         //        var ctobj = newtbllist[i];                         //        coursetbl ct = db.courses.asnotracking().firstordefault(x => x.id == ctobj.id);                         //        results = utilitymethods<coursetbl, int>.editentity(db, ctobj);                         //    }                         //    break;                         //case "coursedesctbl":                         //    (int = 0; < newtbllist.count; i++)                         //    {                         //        var cdtobj = newtbllist[i];                         //        coursedesc cd = db.coursedesc.asnotracking().firstordefault(x => x.id == cdtobj.id);                         //        results = utilitymethods<coursedesc, int>.editentity(db, cdtobj);                         //    }                         //    break;                         //case "coursesubdesc":                         //    (int = 0; < newtbllist.count; i++)                         //    {                         //        var csdobj = newtbllist[i];                         //        coursesubdesc csd = db.coursesubdesc.asnotracking().firstordefault(x => x.id == csdobj.id);                         //        results = utilitymethods<coursesubdesc, int>.editentity(db, csdobj);                         //    }                         //    break;                         //case "interntbl":                         //    (int = 0; < newtbllist.count; i++)                         //    {                         //        var itobj = newtbllist[i];                         //        internship = db.interns.asnotracking().firstordefault(x => x.id == itobj.id);                         //        results = utilitymethods<internship, int>.editentity(db, itobj);                         //    }                         //    break;                         case "locationtbl":                             (int = 0; < newtbllist.count; i++)                             {                                 var ltobj = newtbllist[i];                                 locationtbl lt = db.loc.asnotracking().firstordefault(x => x.id == ltobj.id);                                 results = utilitymethods<locationtbl, int>.editentity(db, ltobj);                             }                             break;                     }                      var resultlist = new list<object>();                     foreach (var item in db.set(tabletype))                     {                         resultlist.add(item);                     }                      return new jsonresult { data = resultlist, jsonrequestbehavior = jsonrequestbehavior.allowget };                 }              }          }         catch (exception ex)         {              return new jsonresult { data = ex.message, jsonrequestbehavior = jsonrequestbehavior.allowget };         }     } 

i've been searching internet while , found related links link1

and link2

but can't find solution problem. please help!!


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -