public ActionResult Register([Bind(Include = "Name, Password, ConfirmedPassword, Email, PhoneNumber,RoleName,Roles")] UserRegistrationViewModel userRegistrationViewModel) { userRegistrationViewModel.roles = roleBasicDTOList.roles; try { ModelState.Remove("roles"); if (ModelState.IsValid) { UserDTO userDTO = RegistrationMapper.Map <UserRegistrationViewModel, UserDTO>(userRegistrationViewModel); UserBasicDTO userBasicDTO = userBusinessContext.RegisterUser(userDTO); return(View("Success")); } else { return(View(userRegistrationViewModel)); } } catch (UserNameAlreadyExistsException) { ModelState.AddModelError("", "Username is already taken"); return(View(userRegistrationViewModel)); } catch (Exception ex) { ModelState.AddModelError("", "Something went wrong. Please try after some time"); } return(View("Error")); }
public ActionResult Register([Bind(Include = "Name,Password,ConfirmedPassword,Email,PhoneNumber,RoleName,Roles")] RegistrationViewModel registrationViewModel) { registrationViewModel.Roles = roleList.Roles; try { //registrationViewModel = RegisterationRoleMapper.Map<RolesDTO, RegistrationViewModel>(roleList); ModelState.Remove("Roles"); if (ModelState.IsValid) { UserRegisterDTO userRegisterDTO = RegistrationViewModelMapper.Map <RegistrationViewModel, UserRegisterDTO>(registrationViewModel); UserInfoDTO newUserInfoDTO = userBusinessContext.RegisterUser(userRegisterDTO); return(View("Success")); } else { return(View(registrationViewModel)); } } catch (EmailAlreadyExistsException ex) { ModelState.AddModelError("Email", "Email id already Registered"); return(View(registrationViewModel)); } catch (Exception exception) { ModelState.AddModelError("", "Something went wrong.Please try after some time"); } return(View("Error")); }
public ActionResult Register([Bind(Include = "Name,Password,ConfirmedPassword,Email,PhoneNumber,RoleName,Roles")] RegistrationViewModel registrationViewModel) { registrationViewModel.Roles = roleList.Roles; try { //registrationViewModel = RegisterationRoleMapper.Map<RolesDTO, RegistrationViewModel>(roleList); ModelState.Remove("Roles"); if (ModelState.IsValid) { UserRegisterDTO userRegisterDTO = RegistrationViewModelMapper.Map <RegistrationViewModel, UserRegisterDTO>(registrationViewModel); UserInfoDTO newUserInfoDTO = userBusinessContext.RegisterUser(userRegisterDTO); return(View("Success")); } else { return(View(registrationViewModel)); } } catch (EmailAlreadyExistsException ex) { ModelState.AddModelError("Email", "Email id already Registered"); return(View(registrationViewModel)); } catch (Exception ex) { return(RedirectToAction("ExceptionCatch", "Static", new { exception = ex.Message })); } }
public ActionResult Index([Bind(Include = "Name, Email, Password, PhoneNumber")] RegisterModel registerModel) { try { if (ModelState.IsValid) { UserRegisterDTO userRegisterDTO = RegistrationVMMapper.Map <RegisterModel, UserRegisterDTO>(registerModel); UserBasicDTO userBasicDTO = userBusinessContext.RegisterUser(userRegisterDTO); return(View("Success")); } else { return(View(registerModel)); } } catch (Exception ex) { ModelState.AddModelError("", ex + ":Exception occured"); } return(View("Error")); }