public static user Update(user user) { try { user.roleName = RoleConstant.Member; user.status = "active"; user current = db.users.Find(user.userID); if (string.IsNullOrEmpty(user.password)) { user.password = current.password; } else { user.password = UserService.EncodePass(user.password); } user.userName = current.userName; db.Entry(current).CurrentValues.SetValues(user); db.SaveChanges(); } catch (Exception) { return null; } return user; }
public ActionResult Edit(user user) { if (ModelState.IsValid) { UserBusiness.Update(user); return RedirectToAction("Index"); } return PartialView("EditForm", user); }
public ActionResult Create(user user) { if (ModelState.IsValid) { UserBusiness.Add(user); return RedirectToAction("Index"); } return PartialView("CreateForm", user); }
public static user Add(user user) { try { user.password = UserService.EncodePass(user.password); user.roleName = RoleConstant.Member; user.status = "active"; db.users.Add(user); //endcode pass word db.SaveChanges(); } catch (Exception) { return null; } return user; }