public ActionResult Save(userInfo user) { if (!ModelState.IsValid) { var viewModel = new designerViewModel() { User = user, StyleTypes = _context.designStyles.ToList() }; return(View("CustomerForm", viewModel)); } if (user.Id == 0) { _context.Users.Add(user); } else { var userInDb = _context.Users.SingleOrDefault(u => u.Id == user.Id); userInDb.Name = user.Name; userInDb.email = user.email; userInDb.phoneNumber = user.phoneNumber; userInDb.StyleTypesId = user.StyleTypesId; userInDb.PicturePath = user.PicturePath; } _context.SaveChanges(); return(RedirectToAction("Designers", "UserInfo")); }
public ActionResult CustomerForm() { var designStyle = _context.designStyles.ToList(); var newDesigner = new designerViewModel { User = new userInfo(), StyleTypes = designStyle }; return(View("CustomerForm", newDesigner)); }
public ActionResult Edit(int id) { var user = _context.Users.SingleOrDefault(c => c.Id == id); if (user == null) { return(HttpNotFound()); } var viewModel = new designerViewModel { User = user, StyleTypes = _context.designStyles.ToList() }; return(View("CustomerForm", viewModel)); }