public bool StudentExist(string studentNumber, string password) { using (var userContext = new ceit_gwa_databaseEntities1()) { //var user = userContext.CeitUsers.Where(u => u.LoginAccount == studentNumber && u.Password == password).FirstOrDefault(); try { var test = userContext.CeitUsers.Where(u => u.LoginAccount == studentNumber && u.Password == password).FirstOrDefault(); } catch (Exception ex) { DebugErrorMessage.CatchError(ex); } string user = null; //user = Convert.ToString(userContext.CeitUsers.Where(u => u.LoginAccount == studentNumber && u.Password == password).FirstOrDefault()); if (user != null) { return(true); } else { return(false); } } }
protected virtual void Seed(ceit_gwa_databaseEntities1 context) { /// Our seed code string newid = Convert.ToString(Guid.NewGuid()); //var admin = new CeitAdministrator { AdminId = newid, AdminName = "admin" }; //var user = new CeitUser { AdminAccount = newid, Roles = 2, DateCreated = DateTime.Now, DateUpdated = DateTime.Now, Password = "******" }; context.CeitAdministrators.Add(new CeitAdministrator { AdminId = newid, AdminName = "admin" }); context.CeitUsers.Add(new CeitUser { AdminAccount = newid, Roles = 2, DateCreated = DateTime.Now, DateUpdated = DateTime.Now, Password = "******" }); context.CeitCourses.Add(new CeitCourse { Name = "CPE", Text = "CPE", Value = "BS in Computer Engineering", Status = "Active" }); context.CeitCourses.Add(new CeitCourse { Name = "ICT", Text = "ICT", Value = "Information Communication Technology", Status = "Active" }); context.CeitCourses.Add(new CeitCourse { Name = "CPET", Text = "CPET", Value = "Computer Engineering Technology", Status = "Active" }); context.CeitSecurityQuestions.Add(new CeitSecurityQuestion { SecurityQuestions = "What is your favorite color?" }); context.CeitUserRoles.Add(new CeitUserRole { Roles = "Student", RolesFor = "Students" }); context.CeitUserRoles.Add(new CeitUserRole { Roles = "Admin", RolesFor = "Administrators" }); context.CeitUserRoles.Add(new CeitUserRole { Roles = "SuperUser", RolesFor = "SuperUsers" }); context.CeitYearLevels.Add(new CeitYearLevel { YearLevel = "1st Year" }); context.CeitYearLevels.Add(new CeitYearLevel { YearLevel = "2nd Year" }); context.CeitYearLevels.Add(new CeitYearLevel { YearLevel = "3rd Year" }); context.CeitYearLevels.Add(new CeitYearLevel { YearLevel = "4th Year" }); context.CeitYearLevels.Add(new CeitYearLevel { YearLevel = "5th Year" }); //context.SaveChanges(); try { context.SaveChanges(); } catch (Exception ex) { DebugErrorMessage.CatchError(ex); } }