public void UpdatePupil(Pupil pupil)
 {
     using (var ctx = new ClassListDbContext())
     {
         ctx.Pupils.Update(pupil);
         ctx.SaveChanges();
     }
 }
 public void UpdateForm(Form form)
 {
     using (var ctx = new ClassListDbContext())
     {
         ctx.Forms.Update(form);
         ctx.SaveChanges();
     }
 }
 public void AddPupil(Pupil pupil)
 {
     using (var ctx = new ClassListDbContext())
     {
         if (ctx.Pupils.Any(p => p.Class == pupil.Class && p.Firstname == pupil.Firstname && p.Lastname == pupil.Lastname))
         {
             return;
         }
         ctx.Pupils.Add(pupil);
         ctx.SaveChanges();
     }
 }
        public void RemovePupil(Pupil pupil)
        {
            using (var ctx = new ClassListDbContext())
            {
                if (!ctx.Pupils.Contains(pupil))
                {
                    return;
                }

                ctx.Pupils.Remove(pupil);
                ctx.SaveChanges();
            }
        }
        public void RemoveForm(Form form)
        {
            using (var ctx = new ClassListDbContext())
            {
                if (!ctx.Forms.Contains(form))
                {
                    return;
                }

                ctx.Forms.Remove(form);
                ctx.SaveChanges();
            }
        }
        public void AddForm(Form form)
        {
            using (var ctx = new ClassListDbContext())
            {
                if (ctx.Forms.Any(f => f.Name == form.Name))
                {
                    return;
                }

                ctx.Forms.Add(form);
                ctx.SaveChanges();
            }
        }