Пример #1
0
 public ActionResult RegisterUser(RegistrationModel registrationModel)
 {
     if (ModelState.IsValid)
     {
         if (!_userBl.IsLoginBooked(registrationModel.Login))
         {
             var user = new User
             {
                 LastName     = registrationModel.LastName,
                 Login        = registrationModel.Login,
                 PhoneNumber  = registrationModel.PhoneNumber,
                 Email        = registrationModel.Email,
                 Password     = registrationModel.Password,
                 Role         = (int)RolesEnum.Client,
                 Status       = (int)UserStatusEnum.Active,
                 UserName     = registrationModel.FirstName,
                 DriverStatus = null
             };
             _userBl.CreateUser(user);
             //Session["UserFullName"] = user.UserName + " " + user.LastName;
             //Session["UserLogin"] = user.Login;
             FormsAuthentication.SetAuthCookie(user.Login, false);
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             ModelState.AddModelError("", "Such login already exists");
         }
     }
     return(View(registrationModel));
 }