public async Task <MicrosoftDynamicsCRMadoxioApplication> GetApplicationByIdWithChildren(string id) { MicrosoftDynamicsCRMadoxioApplication result; try { string[] expand = { "adoxio_localgovindigenousnationid", "adoxio_application_SharePointDocumentLocations", "adoxio_application_adoxio_tiedhouseconnection_Application", "adoxio_AssignedLicence", // "adoxio_Applicant", obtained by a second call as we need to expand it "adoxio_ApplicationTypeId", // "adoxio_LicenceType", Licence Type is obtained by a second call below as we also need to expand it. "adoxio_LicenceFeeInvoice", "adoxio_Invoice", "adoxio_SecondaryApplicationInvoice", "adoxio_localgovindigenousnationid", "adoxio_PoliceJurisdictionId", "adoxio_application_SharePointDocumentLocations", "adoxio_adoxio_application_adoxio_applicationtermsconditionslimitation_Application" }; // fetch from Dynamics. result = await Applications.GetByKeyAsync(id, expand : expand); if (result._adoxioLicencetypeValue != null) { result.AdoxioLicenceType = GetAdoxioLicencetypeById(Guid.Parse(result._adoxioLicencetypeValue)); } if (result.AdoxioApplicationTypeId != null) // expand the application type contents { var filter = $"_adoxio_applicationtype_value eq { result.AdoxioApplicationTypeId.AdoxioApplicationtypeid}"; var typeContents = Applicationtypecontents.Get(filter: filter).Value; result.AdoxioApplicationTypeId.AdoxioApplicationtypeAdoxioApplicationtypecontentApplicationType = typeContents; } if (result._adoxioApplicantValue != null) { result.AdoxioApplicant = await GetAccountByIdAsync(Guid.Parse(result._adoxioApplicantValue)); } if (result.AdoxioAssignedLicence != null && result.AdoxioAssignedLicence._adoxioEstablishmentValue != null) { result.AdoxioAssignedLicence.AdoxioEstablishment = GetEstablishmentById(Guid.Parse(result.AdoxioAssignedLicence._adoxioEstablishmentValue)); } } catch (HttpOperationException) { result = null; } return(result); }
public async Task <MicrosoftDynamicsCRMadoxioApplication> GetApplicationByIdWithChildren(string id) { MicrosoftDynamicsCRMadoxioApplication result; try { string[] expand = { "adoxio_localgovindigenousnationid", "adoxio_application_SharePointDocumentLocations", "adoxio_application_adoxio_tiedhouseconnection_Application", "adoxio_AssignedLicence", "adoxio_ApplicationTypeId", "adoxio_LicenceFeeInvoice", "adoxio_Invoice" }; // fetch from Dynamics. result = await Applications.GetByKeyAsync(id, expand : expand); if (result._adoxioLicencetypeValue != null) { result.AdoxioLicenceType = GetAdoxioLicencetypeById(Guid.Parse(result._adoxioLicencetypeValue)); } if (result.AdoxioApplicationTypeId != null) { var filter = $"_adoxio_applicationtype_value eq { result.AdoxioApplicationTypeId.AdoxioApplicationtypeid}"; var typeContents = this.Applicationtypecontents.Get(filter: filter).Value; result.AdoxioApplicationTypeId.AdoxioApplicationtypeAdoxioApplicationtypecontentApplicationType = typeContents; } if (result._adoxioApplicantValue != null) { result.AdoxioApplicant = await GetAccountById(Guid.Parse(result._adoxioApplicantValue)); } if (result.AdoxioAssignedLicence != null && result.AdoxioAssignedLicence._adoxioEstablishmentValue != null) { result.AdoxioAssignedLicence.AdoxioEstablishment = GetEstablishmentById(Guid.Parse(result.AdoxioAssignedLicence._adoxioEstablishmentValue)); } } catch (HttpOperationException) { result = null; } return(result); }