public ActionResult Index() { List <User> users = db.Users.ToList(); UsersResponseVM usersResponseVM = new UsersResponseVM() { Users = users }; return(View(usersResponseVM)); }
public ActionResult ManageSold(UsersResponseVM usersResponseVM) { if (ModelState.IsValid) { User user = usersResponseVM.User; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(View(usersResponseVM)); }
public ActionResult ManageSold(int id) { User user = db.Users.Find(id); UsersResponseVM usersResponseVM = new UsersResponseVM { User = user }; return(View(usersResponseVM)); }
public ActionResult Edit(UsersResponseVM userVM) { if (ModelState.IsValid) { User user = userVM.User; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); Response.Cookies["userId"]["name"] = user.FirstName; Response.Cookies["userId"]["roleId"] = user.RoleID.ToString(); return(RedirectToAction("Index", "Home")); } return(View(userVM)); }
// GET: User/Edit/id public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } User user = db.Users.Find(id); if (user == null) { return(HttpNotFound()); } UsersResponseVM usersResponseVM = new UsersResponseVM() { User = user }; return(View(usersResponseVM)); }