Пример #1
0
        public async Task <IActionResult> CustomerSettingPage(CustomerSettingView model)
        {
            Customer customer = await unitOfWork.Customers.Get(model.Id);

            if (customer != null)
            {
                foreach (var number in model.Phone)
                {
                    if (!char.IsDigit(number))
                    {
                        ViewBag.Message = "Phone number is invalid!";
                        return(View("EditPhoneError"));
                    }
                }

                customer.Name        = model.FirstName;
                customer.Surname     = model.SecondName;
                customer.PhoneNumber = model.Phone;

                ApplicationUser user = await userManager.FindByEmailAsync(model.Email);

                user.UserName = model.Email;

                unitOfWork.Customers.Update(customer);
                await unitOfWork.SaveAsync();
            }

            return(RedirectToAction("Index", "Home"));
        }
Пример #2
0
        public IActionResult CustomerSettingPage()
        {
            string   name     = User.Identity.Name;
            Customer customer = unitOfWork.Customers.GetAll().Where(c => c.Email == name)
                                .FirstOrDefault();

            if (customer != null)
            {
                CustomerSettingView model = new CustomerSettingView
                {
                    Id         = customer.CustomerId,
                    FirstName  = customer.Name,
                    SecondName = customer.Surname,
                    Phone      = customer.PhoneNumber,
                    Email      = customer.Email,
                    BirthDate  = customer.BirthDate
                };


                return(View(model));
            }

            return(RedirectToAction("Index", "Home"));
        }