public static IQueryable<Qualification> GetAllQualifications()
 {
     using (DatabaseContext repo = new DatabaseContext())
     {
         return repo.Qualifications.OrderBy(q => q.Class);
     }
 }
        public static Qualification GetQualificationByNameAndModel(string name,string model)
        {
            using (DatabaseContext repo = new DatabaseContext())
            {
                var q = new Qualification();

                var result = repo.Qualifications.FirstOrDefault(ql => (ql.DriverName == name && ql.CarModel == model));
                if(result != null)
                {
                    return result;
                }
                return q;
            }
        }
        public static void AddQualificationInstance(Qualification model)
        {
            Qualification exists;
            using (DatabaseContext repo = new DatabaseContext())
            {
                exists = repo.Qualifications.FirstOrDefault(q => q.Id == model.Id);

                if (exists != null)
                {
                    exists.CompletedLaps = model.CompletedLaps;
                    exists.Qualified = model.Qualified;
                    exists.TenInARow = model.TenInARow;
                }
                else
                {
                    exists = model;
                    repo.Qualifications.Add(exists);
                }

                repo.SaveChanges();
            }
        }