public bool AddToDatabase(StudentsContext db) { if (db.Students.Any(x => x.UserName == this.UserName)) { return(false); } else { db.Students.Add(this); db.SaveChanges(); } return(true); }
public bool LoadStudent(StudentsContext db) { if (db.Students.Any(x => x.UserName == this.UserName && x.Password == this.Password)) { var student = db.Students.Where(x => x.UserName == this.UserName).FirstOrDefault(); this.id = student.id; this.FirstName = student.FirstName; this.LastName = student.LastName; this.Email = student.Email; return(true); } else { return(false); } }