public override bool ValidateUser(string username, string password)
 {
     var db = new GameReviewWebsiteEntities();
     //Generates the query for logging in, then converts it to a list, then runs the 
     //Linq Any function on the list which is equivelent of the boolean experssion (list.Count() > 0):
     var userIsValid = db.Gamers.Where(x => x.Name == username).ToList().Any(x => x.Password == password);
     return userIsValid;
 }
 //Insert statement to add a new user
 private static void CreateNewUser(RegisterModel model)
 {
     //Entity Framework classes generated by the database schema are used to insert into the database
     var db = new GameReviewWebsiteEntities();
     db.Gamers.Add(new Gamer()
                       {
                           Biography = model.Bio,
                           Name = model.UserName,
                           Password = model.Password
                       });
     db.SaveChanges();
 }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var gamer = (RegisterModel)validationContext.ObjectInstance;
            if (gamer == null) return null;
            var db = new GameReviewWebsiteEntities();
            var user = db.Gamers.FirstOrDefault(u => u.Name.ToLower() == gamer.UserName.ToLower());

            if (user == null)
                return ValidationResult.Success;
            else
                return new ValidationResult("User already exists");
        }