public ActionResult Accounts()
 {
     if (!Profile.IsAuthenticated) return RedirectToAction("Login", new UserLoginModel(Profile));
     // var modelCollection = Profile.GetProfileCollection();
     //var curUser = Profile.CurrentUser;
     //var model = new ProfileModel();
     //model.Avatar = curUser.Avatar;
     //model.Date = curUser.RegistrationDate.ToString();
     //model.Description = curUser.Description;
     //model.Name = curUser.NickName;
     //model.IsCurrent = !string.IsNullOrEmpty(curUser.PasswordHash);
     //if (modelCollection.Count == 0)
     //{
     //    Profile.UserService.SignOut();
     //    return View("Login");
     //}
     //var profileCollectionModel = new ProfileCollectionModel() { ProfileCollection = modelCollection };
     RegistrationModel model = new RegistrationModel(Profile.CurrentUser) {OpenFirstTab = true};
     return View("Registration", model);
 }
 public ActionResult RegistrateUser(RegistrationModel model)
 {
     if (!Profile.IsAuthenticated)
     {
         var emailExist = Profile.UserService.IsEmailExist(model.Email);
         if (model.IsEmailCorrect && model.IsPasswordCorrect && !emailExist)
         {
             if (!Profile.UserService.IsUserRegistered(model.Email, model.Password))
             {
                 model.Culture = Profile.CurrentCulture;
                 Profile.UserService.RegistrateUser(model);
                 Profile.UserService.Login(model.Email, model.Password);
                 return Redirect("/Profile/Accounts");
             }
         }
         else
         {
             var loginModel = new UserLoginModel(Profile);
             loginModel.Email = model.Email;
             if (!model.IsEmailCorrect)
             {
                 loginModel.SignUpEmailIsIncorrect = true;
             }
             if (!model.IsPasswordCorrect)
             {
                 loginModel.SignUpPasswordIsIncorrect = true;
             }
             if (emailExist)
             {
                 loginModel.IsEmailExist = true;
             }
             Session["signup"] = loginModel;
             return RedirectToAction("Login");
         }
     }
     else
     {
         var currentUser = Profile.UserService.UpdateUser(model);
         Profile.UserService.SignOut();
         if (model.IsEmailCorrect && model.IsPasswordCorrect)
         {
             Profile.UserService.Login(model.Email, model.Password);
         }
         else
         {
             Profile.UserService.Login(currentUser);
         }
     }
     return RedirectToAction("Accounts");
 }
 public ActionResult SendNewPassword(UserLoginModel model)
 {
     if (null == model) return View("Login");
     if (model.Password.Length > 0 && model.Password.Length < 65)
     {
         var regmodel = new RegistrationModel();
         regmodel.Culture = Profile.CurrentCulture;
         regmodel.Password = model.Password;
         regmodel.Email = model.Email;
         Profile.UserService.UpdateUserPassword(regmodel);
         Profile.UserService.Login(regmodel.Email, regmodel.Password);
         return RedirectToAction("Registration");
     }
     return View("Login", model);
 }
        public ActionResult DeleteUser(DeleteAccountModel model)
        {
            if (Profile.IsAuthenticated)
            {
                var curUser = Profile.CurrentUser;
                if (!string.IsNullOrEmpty(curUser.PasswordHash))
                {
                    if (!Profile.VerifiedPassword(model.Password))
                    {
                        var regModel = new RegistrationModel(Profile.CurrentUser);
                        regModel.IsConfirmationPasswordInCorrect = true;
                        Session["regModel"] = regModel;
                        return RedirectToAction("Registration");
                    }
                }

                Profile.UserService.DeleteUserFromContext(curUser.Id);
                Profile.UserService.DeleteCurrentUser(curUser);
                //SendDeleteAccountEmail(model.Description, curUser);

            }
            return RedirectToAction("Login", new UserLoginModel(Profile));
        }