public string GetCustomerName()
        {
            if (CookiesService.IsPersonCookiesExist(this))
            {
                string login    = CookiesService.GetLoginCookie(this);
                string password = CookiesService.GetPasswordCookie(this);

                Person person = db.Person.Where(p => p.Email == login).FirstOrDefault();
                person.Customer.Add(db.Customer.Where(c => c.PersonId == person.Id).FirstOrDefault());
                person.Address.Add(db.Address.Where(a => a.PersonId == person.Id).FirstOrDefault());

                if (person.Customer.First() != null)
                {
                    return(person.Customer.First().Name);
                }
                else
                {
                    return(person.Email);
                }
            }
            else
            {
                return("");
            }
        }
        public async Task <IActionResult> Edit([FromRoute] int id)
        {
            string email    = CookiesService.GetLoginCookie(this);
            string password = CookiesService.GetPasswordCookie(this);

            Person person = await repository.GetPerson(email, password);

            if (person.Id != id)
            {
                return(BadRequest());
            }

            UpdateViewBag("Редактор профиля");
            return(View(person));
        }
        protected Person GetCurrentPerson()
        {
            if (CookiesService.IsPersonCookiesExist(this))
            {
                string login    = CookiesService.GetLoginCookie(this);
                string password = CookiesService.GetPasswordCookie(this);

                // password ?
                Person person = db.Person.Where(p => p.Email == login).FirstOrDefault();
                person.Customer.Add(db.Customer.Where(c => c.PersonId == person.Id).FirstOrDefault());
                person.Address.Add(db.Address.Where(a => a.PersonId == person.Id).FirstOrDefault());

                return(person);
            }
            else
            {
                return(null);
            }
        }
        protected bool IsAdmin()
        {
            if (CookiesService.IsPersonCookiesExist(this))
            {
                string login    = CookiesService.GetLoginCookie(this);
                string password = CookiesService.GetPasswordCookie(this);

                Person person = db.Person.Where(p => p.Email == login).FirstOrDefault();
                if (person.AccessLevelId == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        public async Task <IActionResult> Info()
        {
            if (CookiesService.IsPersonCookiesExist(this))
            {
                string email    = CookiesService.GetLoginCookie(this);
                string password = CookiesService.GetPasswordCookie(this);
                User   user     = new User();
                Person person   = await repository.GetPerson(email, password);

                if (person == null)
                {
                    return(BadRequest());
                }
                Customer customer = await repository.GetCustomer(person.Id);

                Address address = await repository.GetAddress(person.Id);

                user = new User()
                {
                    Person   = person,
                    Customer = customer,
                    Address  = address
                };

                // tmp
                if (customer != null)
                {
                    user.ProductOrders = await repository.GetOrders(person);
                }

                UpdateViewBag();
                return(View(user));
            }
            else
            {
                UpdateViewBag("Аутентификация");
                return(RedirectToAction("Login"));
            }
        }