public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Attempt to register the user try { //WebSecurity.CreateUserAndAccount(model.UserName, model.Password); //WebSecurity.Login(model.UserName, model.Password); //return RedirectToAction("Index", "Home"); UserBusinessLayer userBusinessLayer = new UserBusinessLayer(); User registerUser = userBusinessLayer.GetUserDetails(model.UserName, model.Password); if (registerUser.UserId == 0) { userBusinessLayer.RegisterUser(model.UserName, model.Password, model.DisplayName); return(RedirectToAction("Login", "Account")); } else { ModelState.AddModelError("UserExists", "This username already exists !!"); return(View(model)); } } catch (MembershipCreateUserException e) { ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); } } // If we got this far, something failed, redisplay form return(View(model)); }
public IHttpActionResult RegisterUser(User userModel) { using (UserBusinessLayer userbl = new UserBusinessLayer()) { var response = userbl.RegisterUser(userModel); } return(Ok("User Registerd Successfully")); }