public ActionResult Index(User user) { if (userSQLDAL.UsernameExists(user.Username) && userSQLDAL.PasswordIsCorrect(user.Username, user.Password)) { User userWithRoles = new User(); userWithRoles.Username = user.Username; if (userSQLDAL.IsAdmin(user.Username)) { userWithRoles.Administrator = true; } if (userSQLDAL.IsTechnician(user.Username)) { userWithRoles.Technician = true; } if (userSQLDAL.IsResearcher(user.Username)) { userWithRoles.Researcher = true; } if (userSQLDAL.IsPartner(user.Username)) { userWithRoles.Partneruser = true; } Session["currentUser"] = userWithRoles; return(RedirectToAction("Index", "User")); } ModelState.AddModelError("UserName", "Username or password incorrect or doesn't exist"); return(View("Index", user)); }
public ActionResult CreateUser(User newUser) { if (!ModelState.IsValid) { return(View("CreateUser", newUser)); } if (sqlDAL.UsernameExists(newUser.Username)) { return(View("NewUserError")); } sqlDAL.SaveUser(newUser); return(View("SuccessUserAdded", newUser)); }