public IActionResult UserContactDetails(UserContactDetailsViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            AddressOptions addressOptions = _accountProvider.GetAddressOptions(AddressOption.Billing);

            if (addressOptions.HasFlag(AddressOptions.TelephoneMandatory) && String.IsNullOrEmpty(model.Telephone))
            {
                ModelState.AddModelError($"{nameof(model.Telephone)}", Languages.LanguageStrings.InvalidTelephoneNumber);
            }

            if (ModelState.IsValid)
            {
                if (_accountProvider.SetUserAccountDetails(UserId(), model.FirstName, model.LastName, model.Email, model.Telephone))
                {
                    GrowlAdd(Languages.LanguageStrings.ContactDetailsUpdated);
                    return(RedirectToAction(nameof(Index), "Account"));
                }

                ModelState.AddModelError(String.Empty, Languages.LanguageStrings.FailedToUpdateAccount);
            }

            model.Breadcrumbs = GetBreadcrumbs();
            model.CartSummary = GetCartSummary();

            return(View(model));
        }
        public IActionResult UserContactDetails(UserContactDetailsViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            AddressOptions addressOptions = _accountProvider.GetAddressOptions();

            if (addressOptions.HasFlag(AddressOptions.TelephoneMandatory) && String.IsNullOrEmpty(model.Telephone))
            {
                ModelState.AddModelError($"{nameof(model.Telephone)}", "Please enter a valid telephone number");
            }

            if (ModelState.IsValid)
            {
                if (_accountProvider.SetUserAccountDetails(UserId(), model.FirstName, model.LastName, model.Email, model.Telephone))
                {
                    GrowlAdd("Contact details successfully updated");
                    return(RedirectToAction("Index", "Account"));
                }

                ModelState.AddModelError(String.Empty, "Failed to update user account");
            }

            return(View(model));
        }
        public void ChangeUserContactDetails(UserContactDetailsViewModel viewModel, string userId)
        {
            var user = _userRepository.Get(userId);

            user.Name       = viewModel.Name;
            user.Surname    = viewModel.Surname;
            user.Address    = viewModel.Address;
            user.PostalCode = viewModel.PostalCode;
            user.City       = viewModel.City;

            _userRepository.SaveChanges();
        }
        public IActionResult UserContactDetails()
        {
            if (_accountProvider.GetUserAccountDetails(UserId(), out string firstName, out string lastName, out string email,
                                                       out bool emailConfirmed, out string telephone, out bool telephoneConfirmed))
            {
                UserContactDetailsViewModel model = new UserContactDetailsViewModel(firstName, lastName,
                                                                                    email, emailConfirmed, telephone, telephoneConfirmed,
                                                                                    _accountProvider.GetAddressOptions().HasFlag(AddressOptions.TelephoneShow));

                return(View(model));
            }

            throw new InvalidOperationException("Unable to retrieve account details");
        }
        public ActionResult ChangeContactDetails(UserContactDetailsViewModel viewModel)
        {
            ModelState.Remove("Email");
            if (!ModelState.IsValid)
            {
                return(View("UserContactForm", viewModel));
            }

            var userId = User.Identity.GetUserId();

            _userService.ChangeUserContactDetails(viewModel, userId);

            return(RedirectToAction("Index"));
        }
        public UserContactDetailsViewModel GetUserContactDetails(string userId)
        {
            var user = _userRepository.Get(userId);

            var userContactDetails = new UserContactDetailsViewModel
            {
                Name       = user.Name,
                Surname    = user.Surname,
                Email      = user.Email,
                Address    = user.Address,
                PostalCode = user.PostalCode,
                City       = user.City,
            };

            return(userContactDetails);
        }