public async Task <PREDMET> DeleteSubject(int subjectID) { PREDMET dbEntry = new PREDMET(); dbEntry = _context.PREDMET.Find(subjectID); if (dbEntry != null) { _context.PREDMET.Remove(dbEntry); } await _context.SaveChangesAsync(); return(dbEntry); }
public PREDMET GetSubject(int subjectID) { PREDMET dbEntry = new PREDMET(); dbEntry = _context .PREDMET .Include("POLOZENI_ISPITI") .Where(p => p .PredmetID == subjectID && p .POLOZENI_ISPITI .All(x => x .PredmetID == subjectID)) .FirstOrDefault(); return(dbEntry); }
public async Task <int> SaveSubject(PREDMET subject) { if (subject.PredmetID == 0) { _context.PREDMET.Add(subject); } else { PREDMET dbEntry = new PREDMET(); dbEntry = _context.PREDMET.Find(subject.PredmetID); if (dbEntry != null) { dbEntry.Naziv = subject.Naziv; } } return(await _context.SaveChangesAsync()); }