public ActionResult Create(User user) { if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
public void SaveUser(User user) { if (user.UserId == 0) { _context.Users.Add(user); } else { _context.Users.Attach(user); _context.Entry<User>(user).State = System.Data.EntityState.Modified; } _context.SaveChanges(); }
public ActionResult Edit(User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index","Home"); } return View(user); }
public UserActivityViewModel(IEnumerable<User> users, IEnumerable<Activity> activities, User currentUser) { Users = users; Activities = activities; CurrentUser = currentUser; }