//[ValidateAntiForgeryToken] public ActionResult Create(UserDetailedViewModel userForRegistrationViewModel) { try { if (ModelState.IsValid) { UserProfileDTO userProfile = new UserProfileDTO { FirstName = userForRegistrationViewModel.FirstName, LastName = userForRegistrationViewModel.LastName, Email = userForRegistrationViewModel.Email, Password = userForRegistrationViewModel.Password, Address = userForRegistrationViewModel.Address, PassportNumber = userForRegistrationViewModel.PassportNumber, PhoneNumber = userForRegistrationViewModel.PhoneNumber, IsActive = true, IsAdmin = userForRegistrationViewModel.IsAdmin }; userRepository.CreateUser(userProfile); return(RedirectToAction("Index", "Users")); } } catch (Exception ex) { ModelState.AddModelError(string.Empty, "Error!Sorry, something went wrong! Please retry the operation!"); return(View(userForRegistrationViewModel)); } finally { } return(View(userForRegistrationViewModel)); }
public IActionResult Edit(UserDetailedViewModel userViewModel) { if (!ModelState.IsValid) { return(BadRequest()); } var userDto = _mapper.Map <UserDetailedDto>(userViewModel); _userService.UpdateUser(userDto); return(StatusCode(200)); }
public static UserProfileDTO MapUseProfileDetailedViewToDTO(UserDetailedViewModel userProfileDetailViewModel) { UserProfileDTO userProfileDTO = new UserProfileDTO { FirstName = userProfileDetailViewModel.FirstName, LastName = userProfileDetailViewModel.LastName, Email = userProfileDetailViewModel.Email, Password = userProfileDetailViewModel.Password, Address = userProfileDetailViewModel.Address, PassportNumber = userProfileDetailViewModel.PassportNumber, PhoneNumber = userProfileDetailViewModel.PhoneNumber, IsActive = true, IsAdmin = userProfileDetailViewModel.IsAdmin, BankAccountID = userProfileDetailViewModel.BankAccountID }; return(userProfileDTO); }
public static UserDetailedViewModel MapUseProfileDetailedDTOToView(UserProfileDTO userProfileDTO) { UserDetailedViewModel userDetailedViewModel = new UserDetailedViewModel { ID = userProfileDTO.ID, FirstName = userProfileDTO.FirstName, LastName = userProfileDTO.LastName, Email = userProfileDTO.Email, Address = userProfileDTO.Address, PassportNumber = userProfileDTO.PassportNumber, PhoneNumber = userProfileDTO.PhoneNumber, Password = string.Empty, ConfirmPassword = string.Empty, IsAdmin = userProfileDTO.UserRoles.Any(ur => ur.RoleID == (int)RolesEnum.Admin), BankAccountID = userProfileDTO.BankAccountID }; return(userDetailedViewModel); }