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; }
public Pensum Create(Pensum itemToCreate) { var pensum = _context.Pensums.Add(itemToCreate); _context.SaveChanges(); return pensum; }
public void Detach(Pensum pensum) { _context.Entry(pensum).State = EntityState.Detached; }
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); }