Пример #1
0
        public OperationResult <IList <IDepartmentDTO> > GetAll()
        {
            OperationResult <IList <IDepartmentDTO> > getDepartmentRetVal = null;

            try
            {
                IDepartmentDAC         departmentDAC         = (IDepartmentDAC)DACFactory.Instance.Create(DACType.DepartmentDAC);
                IList <IDepartmentDTO> returnedDepartmentDTO = departmentDAC.GetAll();
                if (returnedDepartmentDTO != null)
                {
                    getDepartmentRetVal = OperationResult <IList <IDepartmentDTO> > .CreateSuccessResult(returnedDepartmentDTO, " successfully");
                }
                else
                {
                    getDepartmentRetVal = OperationResult <IList <IDepartmentDTO> > .CreateFailureResult("failed!");
                }
            }
            catch (DACException dacEx)
            {
                getDepartmentRetVal = OperationResult <IList <IDepartmentDTO> > .CreateErrorResult(dacEx.Message, dacEx.StackTrace);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                getDepartmentRetVal = OperationResult <IList <IDepartmentDTO> > .CreateErrorResult(ex.Message, ex.StackTrace);
            }
            return(getDepartmentRetVal);
        }
Пример #2
0
        public OperationResult <IList <IDepartmentDTO> > GetAllDepartments()
        {
            OperationResult <IList <IDepartmentDTO> > getAllDepartmentsReturnValue = null;

            try
            {
                IDepartmentDAC         departmentDAC     = (IDepartmentDAC)DACFactory.Instance.Create(DACType.DepartmentManagerDAC);
                IList <IDepartmentDTO> departmentDTOList = departmentDAC.GetAllDepartments();
                if (departmentDTOList != null)
                {
                    getAllDepartmentsReturnValue = OperationResult <IList <IDepartmentDTO> > .CreateSuccessResult(departmentDTOList);
                }
                else
                {
                    getAllDepartmentsReturnValue = OperationResult <IList <IDepartmentDTO> > .CreateFailureResult("Get All Departments Method Failed");
                }
            }
            catch (DACException dacEx)
            {
                getAllDepartmentsReturnValue = OperationResult <IList <IDepartmentDTO> > .CreateErrorResult(dacEx.Message, dacEx.StackTrace);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                getAllDepartmentsReturnValue = OperationResult <IList <IDepartmentDTO> > .CreateErrorResult(ex.Message, ex.StackTrace);
            }
            return(getAllDepartmentsReturnValue);
        }