public ActionResult Add(EmployeeUser empuser) { using (EmployeeUserManagementModel db = new EmployeeUserManagementModel()) { if (empuser.userID == 0) { db.EmployeeUsers.Add(empuser); db.SaveChanges(); return(Json(new { success = true, message = "New user added successfully" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(empuser).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "User updated successfully" }, JsonRequestBehavior.AllowGet)); } } }
public ActionResult Delete(int id) { using (EmployeeUserManagementModel db = new EmployeeUserManagementModel()) { EmployeeUser empuser = db.EmployeeUsers.Where(x => x.userID == id).FirstOrDefault <EmployeeUser>(); db.EmployeeUsers.Remove(empuser); db.SaveChanges(); return(Json(new { success = true, message = "Employee deleted successfully" }, JsonRequestBehavior.AllowGet)); } }