public ActionResult Create(User user) { if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); return RedirectToAction("Index","Home"); } return View(user); }
public ActionResult Create(CreateUserViewModel viewModel) { if (ModelState.IsValid) { var user = new User(); user.Name = viewModel.Name; user.EmployeeId = viewModel.EmployeeId; user.Email = viewModel.Email; user.Dob = viewModel.Dob; user.Mobile = viewModel.Mobile; db.Users.Add(user); db.SaveChanges(); return RedirectToAction("Index", "Home"); } return View(viewModel); }
public ActionResult Edit(User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(user); }