Пример #1
0
        public Response <CompanyDetailsModel> GetCompanyByID(long companyID)
        {
            var companyResponse = new Response <CompanyDetailsModel>()
            {
                DataItems  = new List <CompanyDetailsModel>(),
                ResultCode = 0
            };

            var companyDetails = new CompanyDetailsModel();

            var company = _organizationStructureDataProvider.GetOrganizationStructureByID(companyID);

            if (company.ResultCode != 0)
            {
                companyResponse.ResultCode    = company.ResultCode;
                companyResponse.ResultMessage = company.ResultMessage;
                return(companyResponse);
            }
            else
            {
                companyDetails.Company = company.DataItems.FirstOrDefault();
            }

            var organizationIdentifiers = _organizationIdentifiersDataProvider.GetOrganizationIdentifiersByID(companyID, OrganizationType.Company.ToString());

            if (organizationIdentifiers.ResultCode != 0)
            {
                companyResponse.ResultCode    = organizationIdentifiers.ResultCode;
                companyResponse.ResultMessage = organizationIdentifiers.ResultMessage;
                return(companyResponse);
            }
            else
            {
                companyDetails.CompanyIdentifiers = organizationIdentifiers.DataItems;
            }

            var companyAddresses = _organizationStructureDataProvider.GetOrganizationAddressByID(companyID);

            if (companyAddresses.ResultCode != 0)
            {
                companyResponse.ResultCode    = companyAddresses.ResultCode;
                companyResponse.ResultMessage = companyAddresses.ResultMessage;
                return(companyResponse);
            }
            else
            {
                companyDetails.Addresses = companyAddresses.DataItems;
            }

            companyResponse.DataItems.Add(companyDetails);
            return(companyResponse);
        }
Пример #2
0
        /// <summary>
        /// Gets the program unit by identifier.
        /// </summary>
        /// <param name="programUnitID">The program unit identifier.</param>
        /// <returns></returns>
        public Response <ProgramUnitDetailsModel> GetProgramUnitByID(long programUnitID)
        {
            var programUnitResponse = new Response <ProgramUnitDetailsModel>()
            {
                DataItems  = new List <ProgramUnitDetailsModel>(),
                ResultCode = 0
            };

            var programUnitDetails = new ProgramUnitDetailsModel();

            var programUnit = _organizationStructureDataProvider.GetOrganizationStructureByID(programUnitID);

            if (programUnit.ResultCode != 0)
            {
                programUnitResponse.ResultCode    = programUnit.ResultCode;
                programUnitResponse.ResultMessage = programUnit.ResultMessage;
                return(programUnitResponse);
            }
            else
            {
                programUnitDetails.ProgramUnit = programUnit.DataItems.FirstOrDefault();
            }

            var reportingUnit = _organizationIdentifiersDataProvider.GetOrganizationIdentifiersByID(programUnitID, OrganizationType.ProgramUnit.ToString());

            if (reportingUnit.ResultCode != 0)
            {
                programUnitResponse.ResultCode    = reportingUnit.ResultCode;
                programUnitResponse.ResultMessage = reportingUnit.ResultMessage;
                return(programUnitResponse);
            }
            else
            {
                programUnitDetails.ReportingUnit = reportingUnit.DataItems.FirstOrDefault();
            }

            var programUnitAddresses = _organizationStructureDataProvider.GetOrganizationAddressByID(programUnitID);

            if (programUnitAddresses.ResultCode != 0)
            {
                programUnitResponse.ResultCode    = programUnitAddresses.ResultCode;
                programUnitResponse.ResultMessage = programUnitAddresses.ResultMessage;
                return(programUnitResponse);
            }
            else
            {
                programUnitDetails.Addresses = programUnitAddresses.DataItems;
            }

            var programUnitHierarchy = _organizationStructureDataProvider.GetOrganizationHierarchyByID(programUnitID, OrganizationType.ProgramUnit.ToString());

            if (programUnitHierarchy.ResultCode != 0)
            {
                programUnitResponse.ResultCode    = programUnitHierarchy.ResultCode;
                programUnitResponse.ResultMessage = programUnitHierarchy.ResultMessage;
                return(programUnitResponse);
            }
            else
            {
                programUnitDetails.ProgramUnitHierarchies = programUnitHierarchy.DataItems;
            }

            var programUnitServices = _organizationStructureDataProvider.GetServiceOrganizationDetailsByID(programUnitID);

            if (programUnitServices.ResultCode != 0)
            {
                programUnitResponse.ResultCode    = programUnitServices.ResultCode;
                programUnitResponse.ResultMessage = programUnitServices.ResultMessage;
                return(programUnitResponse);
            }
            else
            {
                programUnitDetails.ProgramUnitServices = programUnitServices.DataItems;
            }

            var programUnitServiceWorkflows = _organizationStructureDataProvider.GetOrganizationDetailsModuleComponentByDetailID(programUnitID);

            if (programUnitServiceWorkflows.ResultCode != 0)
            {
                programUnitResponse.ResultCode    = programUnitServiceWorkflows.ResultCode;
                programUnitResponse.ResultMessage = programUnitServiceWorkflows.ResultMessage;
                return(programUnitResponse);
            }
            else
            {
                programUnitDetails.ProgramUnitServiceWorkflows = programUnitServiceWorkflows.DataItems;
            }

            programUnitResponse.DataItems.Add(programUnitDetails);
            return(programUnitResponse);
        }