public async Task<ActionResult> Register(RegisterModel model)
 {
     if (ModelState.IsValid)
     {
         ApplicationUser user = new ApplicationUser { UserName = model.Email, Email = model.Email, Age = model.Age };
         IdentityResult result = await UserManager.CreateAsync(user, model.Password);
         if (result.Succeeded)
         {
             user.EmailConfirmed = true;
             await UserManager.AddToRoleAsync(user.Id, "doctor");
             return RedirectToAction("Login", "AddDoctors");
         }
         else
         {
             foreach (string error in result.Errors)
             {
                 ModelState.AddModelError("", error);
             }
         }
     }
     return View(model);
 }
        public async Task<ActionResult> Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.Email, Email = model.Email, Age = model.Age };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                    var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code },
                               protocol: Request.Url.Scheme);

                    await UserManager.SendEmailAsync(user.Id, "Подтверждение электронной почты",
                               "Для завершения регистрации перейдите по ссылке:: <a href=\""
                                                               + callbackUrl + "\">завершить регистрацию</a>");
                    return View("DisplayEmail");
                }
                AddErrors(result);
            }
            return View(model);
        }