public ActionResult CreateEditUser(UserModel model) { if (model.ID == 0) { User userEntity = new User { UserName = model.UserName, Email = model.Email, Password = model.Password, AddedDate = DateTime.UtcNow, ModifiedDate = DateTime.UtcNow, IP = Request.UserHostAddress, UserProfile = new UserProfile { FirstName = model.FirstName, LastName = model.LastName, Address = model.Address, AddedDate = DateTime.UtcNow, ModifiedDate = DateTime.UtcNow, IP = Request.UserHostAddress } }; userService.InsertUser(userEntity); if (userEntity.ID > 0) { return RedirectToAction("index"); } } else { User userEntity = userService.GetUser(model.ID); userEntity.UserName = model.UserName; userEntity.Email = model.Email; userEntity.Password = model.Password; userEntity.ModifiedDate = DateTime.UtcNow; userEntity.IP = Request.UserHostAddress; userEntity.UserProfile.FirstName = model.FirstName; userEntity.UserProfile.LastName = model.LastName; userEntity.UserProfile.Address = model.Address; userEntity.UserProfile.ModifiedDate = DateTime.UtcNow; userEntity.UserProfile.IP = Request.UserHostAddress; userService.UpdateUser(userEntity); if (userEntity.ID > 0) { return RedirectToAction("index"); } } return View(model); }
public void InsertUser(User user) { userRepository.Insert(user); }
public void UpdateUser(User user) { userRepository.Update(user); }
public void DeleteUser(User user) { userProfileRepository.Delete(user.UserProfile); userRepository.Delete(user); }