Exemplo n.º 1
0
 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));
         }
     }
 }
Exemplo n.º 2
0
 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));
     }
 }