public async Task<ActionResult> Index(Authorization model, string returnUrl)
        {

            if (ModelState.IsValid)
            {
                Authorization user = await UserManager.FindAsync(model.Login, model.Password);
                if (user == null)
                {
                    ModelState.AddModelError("", "Неверный логин или пароль.");
                }
                else
                {
                    ClaimsIdentity claim = await UserManager.CreateIdentityAsync(user,
                                            DefaultAuthenticationTypes.ApplicationCookie);
                    AuthenticationManager.SignOut();
                    AuthenticationManager.SignIn(new AuthenticationProperties
                    {
                        IsPersistent = true
                    }, claim);
                    if (String.IsNullOrEmpty(returnUrl))
                        return RedirectToAction("Index", "Home");
                    return Redirect(returnUrl);
                }
            }
            ViewBag.returnUrl = returnUrl;
            return View(model);
        }
 public async Task<ActionResult> Index(Authorization model)
 {
     if (ModelState.IsValid)
     {
         Authorization user = new Authorization {UserName = model.Login, Login = model.Login, Password = model.Password };
         IdentityResult result = await UserManager.CreateAsync(user, model.Password);
         if (result.Succeeded)
         {
             _authDataService.add(user.Id, model.Profile.FirstName,  model.Profile.LastName, model.Profile.PatronymicName,model.Profile.Birthday, model.Profile.City, model.Profile.Contact);
             return RedirectToAction("Index", "Authorization");
         }
         else
         {
             foreach (string error in result.Errors)
             {
                 ModelState.AddModelError("", error);
             }
         }
     }
     return View(model);
 }