コード例 #1
0
        public async Task<ActionResult> Edit(EditModel model)
        {
            ApplicationUser user = await UserManager.FindByEmailAsync(User.Identity.Name);
            if (user != null)
            {
                user.Year = model.Year;
                IdentityResult result = await UserManager.UpdateAsync(user);
                if (result.Succeeded)
                {
                    return RedirectToAction("Index", "Account");
                }
                else
                {
                    ModelState.AddModelError("", "Что-то пошло не так");
                }
            }
            else
            {
                ModelState.AddModelError("", "Пользователь не найден");
            }

            return View(model);
        }
コード例 #2
0
 public async Task<ActionResult> Edit()
 {
     ApplicationUser user = await UserManager.FindByEmailAsync(User.Identity.Name);
     if (user != null)
     {
         EditModel model = new EditModel { Year = user.Year };
         return View(model);
     }
     return RedirectToAction("Login", "Account");
 }