public IActionResult Create(CreateUserVM userViewModel) { if (ModelState.IsValid) { User user = new User() { AddedDate = DateTime.UtcNow, IPAddress = HttpContext.Connection.RemoteIpAddress.ToString(), Password = userViewModel.Password, Email = userViewModel.Email, UserName = userViewModel.UserName, }; UserProfile userProfile = new UserProfile { AddedDate = DateTime.UtcNow, IPAddress = HttpContext.Connection.RemoteIpAddress.ToString(), Address = userViewModel.Address, FirstName = userViewModel.FirstName, LastName = userViewModel.LastName, Phone = userViewModel.Phone, }; user.UserProfile = userProfile; _userRepository.Insert(user); _userRepository.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(View(userViewModel)); }
public void InsertUser(User user) { _userRepository.Insert(user); }