//
        // GET: /Manage/Index
        public async Task <ActionResult> Index(ManageMessageId?message)
        {
            ViewBag.StatusMessage =
                message == ManageMessageId.ChangePasswordSuccess ? "Ваш пароль изменен."
                : message == ManageMessageId.SetPasswordSuccess ? "Пароль задан."
                : message == ManageMessageId.SetTwoFactorSuccess ? "Настроен поставщик двухфакторной проверки подлинности."
                : message == ManageMessageId.Error ? "Произошла ошибка."
                : message == ManageMessageId.AddPhoneSuccess ? "Ваш номер телефона добавлен."
                : message == ManageMessageId.RemovePhoneSuccess ? "Ваш номер телефона удален."
                : "";

            var             userId   = User.Identity.GetUserId();
            List <Location> location = new List <Location>();

            location = (await GetLocations(userId)).ToList();

            IndexViewModel model = new IndexViewModel
            {
                HasPassword       = HasPassword(),
                PhoneNumber       = await UserManager.GetPhoneNumberAsync(userId),
                TwoFactor         = await UserManager.GetTwoFactorEnabledAsync(userId),
                Logins            = await UserManager.GetLoginsAsync(userId),
                BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId),
                Email             = await UserManager.GetEmailAsync(userId),
                Locations         = location,
                Role = (await UserManager.GetRolesAsync(userId)).First()
            };

            model.ApplicationUsers = new List <ApplicationUser>();
            model.Customers        = new List <Customer>();

            if (model.Role == "Admin")
            {
                using (var context = new ApplicationDbContext())
                {
                    foreach (var v in context.Users.Where(d => d.CreatorId == userId).ToList())
                    {
                        model.ApplicationUsers.Add(v);
                    }
                }

                using (var context = new ProductContolEntities())
                {
                    foreach (var v in context.Customers)
                    {
                        model.Customers.Add(v);
                    }
                }
            }

            return(View(model));
        }
        public async Task <ActionResult> CreateCustomer(CreateCustomerViewModel model)
        {
            var userId   = User.Identity.GetUserId();
            var customer = new Models.Customer
            {
                Name    = model.Name,
                Address = model.Address,
            };

            using (var context = new ProductContolEntities())
            {
                context.Customers.Add(customer);

                await context.SaveChangesAsync();
            }
            return(RedirectToAction("Index", "Home", new { area = "" }));
        }