send an object with a quantity of data from the View to the Controller in ASP.net MVC and AngularJS
VIEW
var Person = {}; Person.IdPerson = 69425; Person.Year = new Date().getFullYear(); $http.post('/API/Update_Person', { params: { Person: Person } }).then(function (response) { });
CONTROLLER
public JsonResult Update_Person(ModelPerson Person) { var person = (from c in db.Person where c.IdPerson == Person.IdPerson && c.Year == Person.Year select c).FirstOrDefault(); return new JsonResult { Data = "OK", JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
more effective method than this?
$http({ method: "post", url: "/API/Person", datatype: "json", data: JSON.stringify(Person) }).then(function (response) { });