public static bool RegisterUser(RegisterModel user) { //check to see if passwords match if (Equals(user.Password, user.Vpassword)) { try { //attempt to insert(add) a new user to the database using (var context = new LoginRegisterContext()) { context.Add <UserInsert>(new UserInsert { UserEmail = user.Email, UserPass = user.Password }); context.SaveChanges(); return(true); } } //if insert fails return false catch { return(false); } } return(false); }
//attempst to verify if a user exists in the database and return a nullable integer public static int?LoginUser(LoginModel login) { using (var context = new LoginRegisterContext()) { //queries the database to see if email and password match the LoginModel int?verify = context.UserInformation .Where(d => d.UserEmail == login.Email && d.UserPass == login.Password) .Select(d => d.UserID) .First(); //return int or null return(verify); } }