public async Task <IActionResult> Index() { // View Model for updating account details UpdateAccountDetailsViewModel viewModel = await GetUpdateAccountDetailsViewModelAsync(); return(View(viewModel)); }
public async Task <IActionResult> Index(UpdateAccountDetailsViewModel viewModel) { // GetCurrentUserAsync() provides more secure access of current users details ApplicationUser currentUser = await GetCurrentUserAsync(); // Update the current users details _userService.UpdateUser(viewModel, currentUser.Id); return(View(viewModel)); }
public async Task <UpdateAccountDetailsViewModel> GetUpdateAccountDetailsViewModelAsync() { // GetCurrentUserAsync() provides more secure access of current users details ApplicationUser currentUser = await GetCurrentUserAsync(); // populate viewModel with current users details UpdateAccountDetailsViewModel viewModel = new UpdateAccountDetailsViewModel() { Email = currentUser.Email, FirstName = currentUser.FirstName, LastName = currentUser.LastName, PhoneNumber = currentUser.PhoneNumber, userId = currentUser.Id, UserName = currentUser.UserName }; return(viewModel); }
public IActionResult UpdateUser(string Email, string UserName, string FirstName, string LastName) { // If both username and email are not null, then continue if (Email != null && UserName != null) { // Return the ID of the user with the email - EMAIL'S ARE UNIQUE var id = _userService.GetUserWithEmail(Email).Id; // Populate the model UpdateAccountDetailsViewModel model = new UpdateAccountDetailsViewModel() { Email = Email, FirstName = FirstName, LastName = LastName, UserName = UserName, }; _userService.UpdateUser(model, id); } return(RedirectToAction("ViewUsers", "Customer")); }
public void UpdateUser(UpdateAccountDetailsViewModel model, string userId) { var user = _userRepository.GetUser(userId); if (user != null) { ApplicationUser updatedUser = new ApplicationUser() { Id = userId, CustomerId = user.CustomerId, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, PhoneNumber = model.PhoneNumber, TimeStamp = DateTime.Now, UserName = model.UserName }; _userRepository.UpdateUser(updatedUser); } }