Ejemplo n.º 1
0
        //
        // GET: /Manage/Index
        //public ActionResult Index()
        //{
        //    var userId = getGuid(User.Identity.GetUserId());
        //    var model = _userManager.FindById(userId);

        //   // var model = new IndexViewModel();

        //    return View(model);
        //}

        public async Task<ActionResult> Index(ManageMessageId? message)
        {
            ViewBag.StatusMessage =
                message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
                : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
                : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set."
                : message == ManageMessageId.Error ? "An error has occurred."
                : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added."
                : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
                : message == ManageMessageId.ChangeEmailSuccess ? "Your Email was changed."
                : message == ManageMessageId.ChangeNumberSuccess ? "Your phone number was changed."
                : message == ManageMessageId.ChangeInfoSuccess ? "Your information was changed."
                : "";

            var userId = getGuid(User.Identity.GetUserId());
            var user = _userManager.FindById(userId);

            var 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.ToString())
                //MyCustomField = user.MyCustomField
            };
            model.ChangeCityModel = user.City;
            model.ChangeNameModel = user.Name;
            model.ChangeLastNameModel = user.LastName;
            return View(model);
        }
Ejemplo n.º 2
0
 public async Task<ActionResult> SaveChanges(string city, string name, string lastName)
 {
     if (User.Identity.IsAuthenticated)
     {
         var user = await _userManager.FindByIdAsync(getGuid(User.Identity.GetUserId()));
         var model = new IndexViewModel();
         user.City = Request.Form["City"];
         user.Name = Request.Form["Name"];
         user.LastName = Request.Form["LastName"];
         _userManager.Update(user);
         return RedirectToAction("Index", new { Message = ManageMessageId.ChangeInfoSuccess });
     }
         return RedirectToAction("Index", new { Message = "You are not logged in."});
 }