/// <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); }