public ActionResult Create(int id, [Bind("ID", "Name", "Gender")] User user) { try { var errorMessage = GetErrorIfInvalid(user); if (!string.IsNullOrWhiteSpace(errorMessage)) { return(RedirectToAction("Index", "Error", new { error = errorMessage })); } var userToAdd = new User { ID = user.ID, Name = user.Name, Gender = user.Gender }; _userBl.AddUser(user.ID, user.Name, user.Gender); return(RedirectToAction("Index", "Admin")); } catch { return(RedirectToAction("Index", "Error")); } }
public ActionResult Create(int id, [Bind("Gender", "UserName", "Password", "Email")] User user) { try { var errorMessage = GetErrorIfInvalid(user, true); if (!string.IsNullOrWhiteSpace(errorMessage)) { return(RedirectToAction("Index", "Error", new { error = errorMessage })); } var userToAdd = new User { Gender = user.Gender, UserName = user.UserName, Password = user.Password, Email = user.Email, IsAdmin = false }; _userBl.AddUser(userToAdd); SetUserInSession(userToAdd.UserName, user.IsAdmin); return(RedirectToAction("Index", "About")); } catch { return(RedirectToAction("Index", "Error")); } }
public string PostMoreAlbums([FromBody] User user) { int usersCreated = userBl.AddUser(user); if (usersCreated != 0) { return(usersCreated + " Object created!"); } return("No object created"); }
public bool AddUser(User user) { return(_userBl.AddUser(user)); }