public async Task<ActionResult> Edit(EditModel model)
 {
     ApplicationUser user = await UserManager.FindByIdAsync(UserId);
     if (user != null)
     {
         user.Email = model.Email;
         user.UserName = model.Login;
         user.FirstName = model.FirstName;
         user.LastName = model.LastName;
         user.Patronymic = model.Patronymic;
         user.Position = model.Position;
         IdentityResult result = await UserManager.UpdateAsync(user);
         if (result.Succeeded)
         {
             FullName = user.FirstName + " " + user.LastName;
             return RedirectToAction("Index", "Main");
         }
         else
         {
             ViewBag.ErrorString = "Не удалось обновить данные. Попробуйте еще раз.";
             return RedirectToAction("Error", "Account");
         }
     }
     else
     {
         ViewBag.ErrorString = "Не удалось найти пользователя. Попробуйте еще раз.";
         return RedirectToAction("Error", "Account");
     }
 }
 public async Task<ActionResult> Edit()
 {
     ApplicationUser user = await UserManager.FindByIdAsync(UserId);
     if (user != null)
     {
         EditModel model = new EditModel
         {
             Login = user.UserName,
             FirstName = user.FirstName,
             LastName = user.LastName,
             Patronymic = user.Patronymic,
             Email = user.Email,
             Position = user.Position
         };
         return View(model);
     }
     return RedirectToAction("Login", "Account");
 }