public List <SubjectDM> GetSubjects(int?ID) { try { var SubjectDetails = ID == 0 ? _DbContext.Subjects : _DbContext.Subjects.Where(s => s.ID == ID); List <SubjectDM> SubjectDMList = new List <SubjectDM>(); foreach (var item in SubjectDetails) { SubjectDM SubDM = new SubjectDM(_GlobalErrors); SubDM.ID = item.ID; SubDM.SubjectTitle = item.SubjectTitle; SubjectDMList.Add(SubDM); } return(SubjectDMList); } catch (Exception ex) { //Errors in this scope indicates system error (not validation errors) //If error not handled, log it and add system error if (!_GlobalErrors.ErrorHandled) { _Logger.Error(ex, "Database Error: Cannot Get SubjectDetails!"); _GlobalErrors.AddSystemError("Database Error: Cannot Get SubjectDetails!"); _GlobalErrors.ErrorHandled = true; } throw; } }
public SubjectDM MapVM_DM() { GlobalErrors globalErrors = new GlobalErrors(); SubjectDM obj = new SubjectDM(globalErrors); obj.ID = ID; obj.SubjectTitle = SubjectTitle; return(obj); }
public void Delete(SubjectDM domain) { try { _SubjectRepo.Delete(domain); } catch (Exception ex) { //Errors in this scope indicates system error (not validation errors) //If error not handled, log it and add system error if (!_GlobalErrors.ErrorHandled) { _Logger.Error(ex, "Database Error: Cannot Delete Subject!"); _GlobalErrors.AddSystemError("Database Error: Cannot Delete Subject!"); _GlobalErrors.ErrorHandled = true; } throw; } }
public SubjectVM(SubjectDM Sub) { ID = Sub.ID; SubjectTitle = Sub.SubjectTitle; }
public SubjectService(GlobalErrors globalErrors) : base(globalErrors) { _SubjectRepo = new SubjectRepository(globalErrors); _SubjectnDM = new SubjectDM(globalErrors); }