public Subject Delete(long subjectId) { try { Subject requestedSubject = _context.Subjects .FirstOrDefault(s => s.SubjectId == subjectId); if (requestedSubject != null) { _context.Remove(requestedSubject); _context.SaveChanges(); return(requestedSubject); } throw new Exception("Subject that you want to delete doesn't exist!"); } catch (Exception ex) { throw new Exception($"Error while trying to find subject! Error: {ex.Message}"); } }
public Professor Delete(string professorId) { try { Professor requestedProfessor = _context.Professors .FirstOrDefault(p => p.Id.Equals(professorId)); if (requestedProfessor != null) { _context.Remove(requestedProfessor); _context.SaveChanges(); return(requestedProfessor); } throw new Exception("Professor that you want to delete doesn't exist!"); } catch (Exception ex) { throw new Exception($"Error while trying to delete professor! Error: {ex.Message}"); } }
public SeminarPaper Delete(long seminarPaperId) { try { SeminarPaper requestedPaper = _context.SeminarPapers .FirstOrDefault(s => s.SeminarPaperId == seminarPaperId); if (requestedPaper != null) { _context.Remove(requestedPaper); _context.SaveChanges(); return(requestedPaper); } throw new Exception("Paper that you want to delete doesn't exist!"); } catch (Exception ex) { throw new Exception($"Error while trying to find paper! Error: {ex.Message}"); } }
public Student Delete(string studentId) { try { Student requestedStudent = _context.Students .FirstOrDefault(p => p.Id.Equals(studentId)); if (requestedStudent != null) { _context.Remove(requestedStudent); _context.SaveChanges(); return(requestedStudent); } throw new Exception("Student that you want to delete doesn't exist!"); } catch (Exception ex) { throw new Exception($"Error while trying to find student! Error: {ex.Message}"); } }