Exemplo n.º 1
0
        public async Task <ActionResult> Edit(string returnUrl)
        {
            var userId = User.Identity.GetUserId <int>();
            var user   = await UserManager.FindByIdAsync(userId);

            var userInformation = userInformationService.GetUserInformation(userId);

            var viewModel = new AccountDetailsViewModel
            {
                Email     = user.Email,
                Name      = user.UserName,
                ReturnUrl = returnUrl,
                Address   = Mapper.Map <Address, AddressViewModel>(userInformation.Address)
            };

            return(View(viewModel));
        }
Exemplo n.º 2
0
        public async Task <ViewResult> Checkout()
        {
            var viewModel = new ShippingInformationViewModel();

            if (!User.Identity.IsAuthenticated)
            {
                return(View(viewModel));
            }

            var user = await UserManager.FindByNameAsync(User.Identity.Name);

            var userInformation = userInformationService.GetUserInformation(user.Id);

            viewModel.Address = Mapper.Map <Address, AddressViewModel>(userInformation.Address);
            viewModel.Name    = user.UserName;
            viewModel.Email   = user.Email;

            return(View(viewModel));
        }
Exemplo n.º 3
0
        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);
        }