public ActionResult UpdateEmp(Datatable.Models.EmployeeModel model) { using (var db = new AzureDatatableEntities()) { var result = db.Employees.SingleOrDefault(b => b.EmpId == model.EmpId); if (result != null) { if (model.Property == "Name") { result.Name = model.Name; } if (model.Property == "Position") { result.Position = model.Position; } if (model.Property == "Location") { result.Office = model.Location; } if (model.Property == "Age") { result.Age = model.Age; } if (model.Property == "Salary") { result.Salary = model.Salary; } db.SaveChanges(); } } return(Json(new { status = "success" }, JsonRequestBehavior.AllowGet)); }
public ActionResult DeleteEmpById(Datatable.Models.EmployeeModel model) { using (var ctx = new AzureDatatableEntities()) { var employer = new AzureSql.Employee { EmpId = model.EmpId }; ctx.Employees.Attach(employer); ctx.Employees.Remove(employer); ctx.SaveChanges(); } return(Json(new { status = "success" }, JsonRequestBehavior.AllowGet)); }