public async Task <ActionResult> Edit([Bind(Include = "userID,fname,lname,username,email,password")] EmployeeUser employeeUser) { if (ModelState.IsValid) { db.Entry(employeeUser).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(employeeUser)); }
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)); } } }