public ActionResult Signup(SignupViewModel signup) //Signup [POST] { if (ModelState.IsValid) { //Auto Mapper. var mapAccount = new MapperConfiguration(configExpression => { configExpression.CreateMap <SignupViewModel, Account>(); }); IMapper mapper = mapAccount.CreateMapper(); var account = mapper.Map <SignupViewModel, Account>(signup); accountBL.AddUser(account); //Method call to add user details return(RedirectToAction("Login")); } return(View()); }
public ActionResult SignUp(SignUpModel userModel) { if (ModelState.IsValid) { bool CanAddUser = userBL.VerifyUser(userModel.UserMailId); if (CanAddUser) { var user = AutoMapper.Mapper.Map <SignUpModel, Account>(userModel); //Automapping user details from model to entity userBL.AddUser(user); //Adding the user details to the database return(RedirectToAction("Login", "Account")); //Redirecting to the login page } else { ModelState.AddModelError("SignUpError", "User already exist"); //Passing login error to the view } } return(View()); }