public async Task <IActionResult> Register(RegisterViewModel model)                   // Register
        {
            if (ModelState.IsValid)
            {
                var result = await _userManagerService.CreateAccount(model);

                if (result.Succeeded)
                {
                    // генерация токена для пользователя
                    var code = await _userManagerService.GenerateEmailConfirmationTokenAsync(model.Account);

                    var callbackUrl = Url.Action(
                        "ConfirmEmail",
                        "Account",
                        new { userId = model.Id, code = code },
                        protocol: HttpContext.Request.Scheme);
                    EmailService emailService = new EmailService();
                    await emailService.SendEmailAsync(model.Email, "Confirm your account",
                                                      $"Confirm the registration by clicking on the link: <a href='{callbackUrl}'>link</a>");

                    return(RedirectToAction("CheckEmailIndex", "Home"));
                }
                else
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError(string.Empty, error.Description);
                    }
                }
            }
            else
            {
                ViewData["Message"] = "Passwords do not match!";
            }
            return(View(model));
        }