Esempio n. 1
0
 public void Detach(Pensum pensum)
 {
     _context.Entry(pensum).State = EntityState.Detached;
 }
Esempio n. 2
0
 public Pensum UpdateNew(Pensum itemToUpdate)
 {
     var updateCourse = false;
     var updateGrade = false;
     var pensum = GetById(itemToUpdate.Id);
     if (pensum.Course.Id != itemToUpdate.Course.Id)
     {
         pensum.Course = itemToUpdate.Course;
         updateCourse = true;
     }
     if (pensum.Grade.Id != itemToUpdate.Grade.Id)
     {
         pensum.Grade = itemToUpdate.Grade;
         updateGrade = true;
     }
     return Update(pensum, updateCourse, updateGrade);
 }
Esempio n. 3
0
 public Pensum Create(Pensum itemToCreate)
 {
     var pensum = _context.Pensums.Add(itemToCreate);
     _context.SaveChanges();
         return pensum;
 }
Esempio n. 4
0
 public Pensum Update(Pensum itemToUpdate, bool updateCourse = true, bool updateGrade = true)
 {
     if (updateCourse)
         _context.Entry(itemToUpdate.Course).State = EntityState.Modified;
     if (updateGrade)
         _context.Entry(itemToUpdate.Grade).State = EntityState.Modified;
     _context.SaveChanges();
     return itemToUpdate;
 }