// // GET: /Manage/Index public async Task<ActionResult> Index(ManageMessageId? message) { ApplicationDbContext db = new ApplicationDbContext(); 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." : ""; var userId = User.Identity.GetUserId(); 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), MinutesBetweenAlerts = db.Users.Single(m => m.UserName == User.Identity.Name).MinutesBetweenAlerts, }; return View(model); }
public async Task<ActionResult> Index(IndexViewModel model) { if (ModelState.IsValid) { ApplicationDbContext db = new ApplicationDbContext(); db.Users.Single(m => m.UserName == User.Identity.Name).MinutesBetweenAlerts = model.MinutesBetweenAlerts; db.SaveChanges(); } return RedirectToAction("Index"); }