Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult Register(UserFormModel form)
- {
- if (ModelState.IsValid)
- {
- var command = new UserRegisterCommand
- {
- FirstName = form.FirstName,
- LastName = form.LastName,
- Email=form.Email,
- Password = form.Password,
- Activated = true,
- RoleId = (Int32)UserRoles.User
- };
- IEnumerable<ValidationResult> errors = commandBus.Validate(command);
- ModelState.AddModelErrors(errors);
- if (ModelState.IsValid)
- {
- var result = commandBus.Submit(command);
- if (result.Success)
- {
- User user = userRepository.Get(u => u.Email == form.Email);
- formAuthentication.SetAuthCookie(this.HttpContext,
- UserAuthenticationTicketBuilder.CreateAuthenticationTicket(
- user));
- return RedirectToAction("Index", "Home");
- }
- }
- }
- // If fail
- return View(form);
- }
Add Comment
Please, Sign In to add comment