public async Task <IActionResult> GetNotifications(HttpRequest request, int?pageRef, int?startYear = null, int?endYear = null, IEnumerable <string> fundingStreamIds = null, IEnumerable <string> allocationLineIds = null, IEnumerable <string> allocationStatuses = null, IEnumerable <string> ukprns = null, IEnumerable <string> laCodes = null, bool?isAllocationLineContractRequired = null, int?pageSize = MaxRecords) { pageSize = pageSize ?? MaxRecords; IEnumerable <string> statusesArray = allocationStatuses.IsNullOrEmpty() ? new[] { "Published" } : allocationStatuses; if (pageRef < 1) { return(new BadRequestObjectResult("Page ref should be at least 1")); } if (pageSize < 1 || pageSize > 500) { return(new BadRequestObjectResult($"Page size should be more that zero and less than or equal to {MaxRecords}")); } SearchFeedV2 <AllocationNotificationFeedIndex> searchFeed = await _feedsService.GetFeedsV2(pageRef, pageSize.Value, startYear, endYear, ukprns, laCodes, isAllocationLineContractRequired, statusesArray, fundingStreamIds, allocationLineIds); if (searchFeed == null || searchFeed.TotalCount == 0 || searchFeed.Entries.IsNullOrEmpty()) { return(new NotFoundResult()); } AtomFeed <AllocationModel> atomFeed = CreateAtomFeed(searchFeed, request); return(Formatter.ActionResult <AtomFeed <AllocationModel> >(request, atomFeed)); }
public async Task <IActionResult> GetLocalAuthorityProvidersResultsForAllocations(string laCode, int startYear, int endYear, string allocationLineIds, HttpRequest request) { if (string.IsNullOrEmpty(laCode)) { return(new BadRequestObjectResult("Missing la code")); } if (startYear == 0) { return(new BadRequestObjectResult("Missing start year")); } if (endYear == 0) { return(new BadRequestObjectResult("Missing end year")); } if (string.IsNullOrEmpty(allocationLineIds)) { return(new BadRequestObjectResult("Missing allocation line ids")); } string[] allocationLineIdsArray = new string[0]; if (!string.IsNullOrWhiteSpace(allocationLineIds)) { allocationLineIdsArray = allocationLineIds.Split(","); } IList <string> allocationLineFilters = new List <string>(); foreach (string allocationLineId in allocationLineIdsArray) { allocationLineFilters.Add($"allocationLineId eq '{allocationLineId}'"); } SearchFeed <AllocationNotificationFeedIndex> searchFeed = await _feedsService.GetLocalAuthorityFeeds(laCode, startYear, endYear, allocationLineFilters); if (searchFeed == null || searchFeed.Entries.IsNullOrEmpty()) { return(new NotFoundResult()); } IEnumerable <AllocationNotificationFeedIndex> entries = ValidateFeedsForLaCode(searchFeed.Entries); if (entries.IsNullOrEmpty()) { return(new NotFoundResult()); } entries = entries.OrderByDescending(o => o.AllocationVersionNumber).DistinctBy(m => m.ProviderId); LocalAuthorityResultsSummary localAuthorityResultsSummary = CreateLocalAuthorityResultsSummary(entries, request); return(Formatter.ActionResult(request, localAuthorityResultsSummary)); }
public async Task <IActionResult> GetProviderResultsForFundingStreams(string providerId, int startYear, int endYear, string fundingStreamIds, HttpRequest request) { if (string.IsNullOrEmpty(providerId)) { return(new BadRequestObjectResult("Missing providerId")); } if (startYear == 0) { return(new BadRequestObjectResult("Missing start year")); } if (endYear == 0) { return(new BadRequestObjectResult("Missing end year")); } if (string.IsNullOrEmpty(fundingStreamIds)) { return(new BadRequestObjectResult("Missing funding stream ids")); } string[] fundingStreamIdsArray = new string[0]; if (!string.IsNullOrWhiteSpace(fundingStreamIds)) { fundingStreamIdsArray = fundingStreamIds.Split(","); } IList <string> fundingStreamFilters = new List <string>(); foreach (string fundingStreamId in fundingStreamIdsArray) { fundingStreamFilters.Add($"fundingStreamId eq '{fundingStreamId}'"); } SearchFeed <AllocationNotificationFeedIndex> searchFeed = await _feedsService.GetFeeds(providerId, startYear, endYear, fundingStreamFilters); if (searchFeed == null || searchFeed.Entries.IsNullOrEmpty()) { return(new NotFoundResult()); } IEnumerable <AllocationNotificationFeedIndex> entries = ValidateFeeds(searchFeed.Entries, checkProfiling: false); if (entries.IsNullOrEmpty()) { return(new NotFoundResult()); } ProviderResultSummary providerResultSummary = CreateProviderResultSummary(entries, request); return(Formatter.ActionResult(request, providerResultSummary)); }
public IActionResult GetAllocationByAllocationResultId(string allocationResultId, HttpRequest httpRequest) { Guard.IsNullOrWhiteSpace(allocationResultId, nameof(allocationResultId)); Guard.ArgumentNotNull(httpRequest, nameof(httpRequest)); PublishedProviderResult publishedProviderResult = _publishedResultsService.GetPublishedProviderResultByVersionId(allocationResultId); if (publishedProviderResult == null) { return(new NotFoundResult()); } AllocationModel allocation = CreateAllocation(publishedProviderResult); return(Formatter.ActionResult <AllocationModel>(httpRequest, allocation)); }
public async Task <IActionResult> GetNotifications(int?pageRef, string allocationStatuses, int?pageSize, HttpRequest request) { if (!pageRef.HasValue) { pageRef = 1; } if (pageRef < 1) { return(new BadRequestObjectResult("Page ref should be at least 1")); } if (!pageSize.HasValue) { pageSize = MaxRecords; } if (pageSize < 1 || pageSize > 500) { return(new BadRequestObjectResult($"Page size should be more that zero and less than or equal to {MaxRecords}")); } string[] statusesArray = statusesArray = new[] { "Published" }; if (!string.IsNullOrWhiteSpace(allocationStatuses)) { statusesArray = allocationStatuses.Split(","); } SearchFeed <AllocationNotificationFeedIndex> searchFeed = await _feedsService.GetFeeds(pageRef.Value, pageSize.Value, statusesArray); if (searchFeed == null || searchFeed.TotalCount == 0) { return(new NotFoundResult()); } AtomFeed <AllocationModel> atomFeed = CreateAtomFeed(searchFeed, request); return(Formatter.ActionResult <AtomFeed <AllocationModel> >(request, atomFeed)); }