// Business Logic pass through code to Select All Sitters public List <SittersEntity> SelectAllSitters() { var returnedEntities = new List <SittersEntity>(); try { using (var repository = new SittersRepository()) { foreach (var entity in repository.SelectAll()) { // CALL GetNetSalary Method to return NetSalary entity.NetSalary = GetNetSalary(entity.GrossSalary, entity.Age); returnedEntities.Add(entity); } } return(returnedEntities); } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); throw new Exception("BusinessLogic:SittersBusiness::SelectAllSitters::Error occured.", ex); } }
// Business Logic pass through code to Delete a Sitter by ID public bool DeleteSitterById(int id) { try { using (var repository = new SittersRepository()) { return(repository.DeleteById(id)); } } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); throw new Exception("BusinessLogic:SittersBusiness::DeleteSitterById::Error occured.", ex); } }
// Business Logic pass through code to Update Sitter public bool UpdateSitter(SittersEntity entity) { try { bool bOpDoneSuccessfully; using (var repository = new SittersRepository()) { bOpDoneSuccessfully = repository.Update(entity); } return(bOpDoneSuccessfully); } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); throw new Exception("BusinessLogic:SittersBusiness::UpdateSitter::Error occured.", ex); } }
// Business Logic pass through code to Select a Sitter by ID public SittersEntity SelectSitterById(int id) { try { SittersEntity returnedEntity; using (var repository = new SittersRepository()) { returnedEntity = repository.SelectById(id); if (returnedEntity != null) { returnedEntity.NetSalary = GetNetSalary(returnedEntity.GrossSalary, returnedEntity.Age); } } return(returnedEntity); } catch (Exception ex) { //Log exception error _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true); throw new Exception("BusinessLogic:SittersBusiness::SelectSitterById::Error occured.", ex); } }