//
        // GET: /Account/Index
        public async Task<ActionResult> Index(ManageMessageId? message)
        {

            if (User.Identity.Name.Equals("*****@*****.**"))
                return RedirectToAction("GuestIndex");

            ViewBag.StatusMessage =
                message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
                : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
                : message == ManageMessageId.SetTwoFactorSuccess ? "Your two factor provider has been set."
                : message == ManageMessageId.Error ? "An error has occurred."
                : message == ManageMessageId.AddPhoneSuccess ? "The phone number was added."
                : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
                : message == ManageMessageId.ProfileUpdateSuccess ? "Your profile has been updated."
                : "";

            var currentUser = UserManager.FindById(User.Identity.GetUserId());
            var model = new IndexViewModel
            {
                User = currentUser,
                HasPassword = HasPassword(),
                TwoFactor = await UserManager.GetTwoFactorEnabledAsync(User.Identity.GetUserId()),
                Logins = await UserManager.GetLoginsAsync(User.Identity.GetUserId()),
                BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(User.Identity.GetUserId())
            };
            return View(model);
        }
 public async Task<ActionResult> Edit()
 {
     var currentUser = UserManager.FindById(User.Identity.GetUserId());
     var model = new IndexViewModel
     {
         User = currentUser,
         HasPassword = HasPassword(),
         TwoFactor = await UserManager.GetTwoFactorEnabledAsync(User.Identity.GetUserId()),
         Logins = await UserManager.GetLoginsAsync(User.Identity.GetUserId()),
         BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(User.Identity.GetUserId())
     };
     return View(model);
 }
        public ActionResult Edit(IndexViewModel indexViewModel)
        {
            if(ModelState.IsValid)
            {
                var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
                var store = new UserStore<ApplicationUser>(new ApplicationDbContext());
                var ctx = store.Context;
                var currentUser = manager.FindById(User.Identity.GetUserId());

                currentUser.FirstName = indexViewModel.User.FirstName;
                currentUser.LastName = indexViewModel.User.LastName;
                currentUser.Address = indexViewModel.User.Address;
                currentUser.City = indexViewModel.User.City;
                currentUser.State = indexViewModel.User.State;
                currentUser.Phone = indexViewModel.User.Phone;
                currentUser.PostalCode = indexViewModel.User.PostalCode;
                manager.Update(currentUser);
                return RedirectToAction("Index", new { message = ManageMessageId.ProfileUpdateSuccess });
            }
            return View(indexViewModel);
        }