Пример #1
0
        public ActionResult Register(RegisterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                _validationMessageService.StoreActionResponseMessageError(ModelState);
                return(View(model));
            }
            User user = null;

            try
            {
                user = model.CreateUser();
                model.SendCofirmEmailIfRequired(user);
                _validationMessageService.StoreActionResponseMessageSuccess("Successfully Registered. Please check your email.");
                return(RedirectToAction("Login"));
            }
            catch (ArgumentException)
            {
                _validationMessageService.StoreActionResponseMessageError("Invalid Email");
            }
            catch (SmtpException)
            {
                _userService.DeleteUser(user.ID);
                _validationMessageService.StoreActionResponseMessageError("Failed to send confirmation email. Please try again.");
            }
            catch (Exception ex)
            {
                _validationMessageService.StoreActionResponseMessageError("Problem has been occurred while proccessing you requst. Please try again.");
                _logger.Error(ex, "User failed to create: UserName={0}, Email={1}", model.Email, model.Email);
            }
            return(View(model));
        }
Пример #2
0
        public ActionResult Index(RegisterViewModel rvm)
        {
            if (Session["UserSession"] == null)
            {
                return(RedirectToAction("Index", "Login"));
            }

            bool status = rvm.CreateUser();

            return(View(rvm));
        }
Пример #3
0
 public IActionResult Register(RegisterViewModel user)
 {
     if (ModelState.IsValid)
     {
         user.UniqueEmail = _context.users.Count(u => u.Email == user.Email);
         TryValidateModel(user);
         if (ModelState.IsValid)
         {
             SaveUserInfoToSession(user.CreateUser(_context));
             return(RedirectToAction("Dashboard", "Belt2"));
         }
     }
     return(View("LoginReg", new LogRegModelBundle()));
 }