Exemple #1
0
 public IActionResult Edit(UserInformationVm userInformation, string token)
 {
     if (userInformation == null)
     {
         return(Ok(ResponseManager.GenerateResponse("Błąd: Informacje dla użytkownika są puste", (int)MessageType.Error, null)));
     }
     else
     {
         _service.EditUserInformation(userInformation);
         return(Ok(ResponseManager.GenerateResponse(null, (int)MessageType.Ok, null)));
     }
 }
        public async Task <IdentityResult> UpdateAsync(
            int userId,
            AccountDto accountDto,
            IUserInformationService userInformationService)
        {
            var storedUser = await FindByIdAsync(userId);

            storedUser.ThrowIfNull();

            if (!string.IsNullOrWhiteSpace(accountDto.Password))
            {
                var validationResult = await PasswordValidator.ValidateAsync(accountDto.Password);

                if (!validationResult.Succeeded)
                {
                    return(validationResult);
                }
            }

            storedUser.Update(accountDto, PasswordHasher);

            var identityResult = await base.UpdateAsync(storedUser);

            if (!identityResult.Succeeded)
            {
                return(identityResult);
            }

            var userInformation       = new UserInformation(Mapper.Map <AddressDto, Address>(accountDto.AddressDto));
            var storedUserInformation = userInformationService.GetUserInformation(storedUser.Id);

            userInformation.UserInformationId = storedUserInformation.UserInformationId;

            await userInformationService.EditUserInformation(userInformation);

            return(identityResult);
        }