Esempio n. 1
0
 public ActionResult Register(RegisterUser user)
 {
     if (ModelState.IsValid)
     {
         user.Password = CryptHelper.GetSha512Base64Hash(user.Login.ToLower() + user.Password);
         var result = ServiceProxySingleton.Instance.RegisterUser(user);
         if (result.IsError())
             ModelState.AddModelError("", result.ErrorMessage);
         else
         {
             user.RegistrationCode = result.AttachedObject;
             var helper = new EmailController("ConfirmEmail", new PasswordMailInfo {UserName = user.UserFio ?? user.Login, Email = user.Email, Code = user.RegistrationCode});
             helper.SendConfirmEmail();
             ViewBag.Success = true;
         }
     }
     else
     {
         var errors =
             ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage).Distinct().ToArray();
         foreach (var e in errors)
             ModelState.AddModelError("", e);
     }
     return View(user);
 }