public async Task <IPaginatedResult <Dtos.EasSubmission> > GetSubmissionValues(CancellationToken cancellationToken, string ukprn = null, int pageSize = 0, int pageNumber = 0) { IPaginatedResult <Dtos.EasSubmission> result; using (var context = _eas1920DbContext()) { var data = context.EasSubmissionValues .Where(x => x.Payment.Fm36); if (!string.IsNullOrEmpty(ukprn)) { data = data.Where(x => x.EasSubmission.Ukprn == ukprn); } var projectedData = data.OrderBy(x => x.EasSubmission.UpdatedOn) .Select(value => new Dtos.EasSubmission() { Ukprn = value.EasSubmission.Ukprn, Amount = value.PaymentValue, SubmissionId = value.SubmissionId, PaymentTypeName = value.Payment.PaymentName, PaymentType = value.PaymentId, SubmissionCollectionPeriod = value.CollectionPeriod, }); result = await PaginatedResultFactory <Dtos.EasSubmission> .CreatePaginatedResultAsync(projectedData, pageSize, pageNumber, cancellationToken); return(result); } }
public async Task <IPaginatedResult <CollectionReturnDto> > GetClosedCollectionEvents(CancellationToken cancellationToken, DateTime?closedCollectionsSince = null, int pageSize = 0, int pageNumber = 0) { IPaginatedResult <CollectionReturnDto> result; closedCollectionsSince = closedCollectionsSince ?? new DateTime(1900, 1, 1); using (var context = _summarisationFactory()) { var data = context.SummarisedActuals.Include(x => x.CollectionReturn) .Where(x => x.CollectionReturn.DateTime > closedCollectionsSince.Value) .GroupBy(y => new { y.CollectionReturn.DateTime, y.CollectionReturn.CollectionType, y.CollectionReturn.CollectionReturnCode }) .Select(grp => new CollectionReturnDto { DateTime = grp.Key.DateTime.GetValueOrDefault(), CollectionReturnCode = grp.Key.CollectionReturnCode, CollectionType = grp.Key.CollectionType, TotalItems = grp.Count() }); result = await PaginatedResultFactory <CollectionReturnDto> .CreatePaginatedResultAsync(data, pageSize, pageNumber, cancellationToken); } return(result); }
public async Task <IPaginatedResult <int> > GetAcademicYears(CancellationToken cancellationToken, DateTime?dateTimeUtc = null, bool?includeClosed = false, int pageSize = 0, int pageNumber = 0) { dateTimeUtc ??= _dateTimeProvider.GetNowUtc(); using (var context = _jobQueDatacontextFactory()) { var collections = await context.ReturnPeriod .Where(x => x.StartDateTimeUtc <= dateTimeUtc && x.Collection.CollectionType.Type == IlrCollectionType) .Select(x => x.Collection.CollectionId) .Distinct() .ToListAsync(cancellationToken); var data = context.ReturnPeriod .Where(x => collections.Contains(x.CollectionId)) .GroupBy(x => new { x.Collection.CollectionYear }) .Select(x => new { CollectionYear = x.Key.CollectionYear.Value, MaxPeriodClosedDate = x.Max(y => y.EndDateTimeUtc) }).AsQueryable(); if (!includeClosed.GetValueOrDefault()) { data = data.Where(y => y.MaxPeriodClosedDate >= dateTimeUtc); } var projectedData = data.Select(x => x.CollectionYear).OrderByDescending(x => x); var result = await PaginatedResultFactory <int> .CreatePaginatedResultAsync(projectedData, pageSize, pageNumber, cancellationToken); return(result); } }
public async Task <IPaginatedResult <SummarisedActualDto> > GetSummarisedActuals(CancellationToken cancellationToken, string collectionType, string collectionReturnCode, int pageSize = 0, int pageNumber = 0) { IPaginatedResult <SummarisedActualDto> result; using (var context = _summarisationFactory()) { var data = context.SummarisedActuals .Where(x => x.CollectionReturn.CollectionReturnCode == collectionReturnCode && x.CollectionReturn.CollectionType == collectionType) .Select(x => new SummarisedActualDto { CollectionReturnCode = collectionReturnCode, CollectionType = collectionType, ActualValue = x.ActualValue, ActualVolume = x.ActualVolume == 0 ? null : (int?)x.ActualVolume, ContractAllocationNumber = x.ContractAllocationNumber, DeliverableCode = x.DeliverableCode, FundingStreamPeriodCode = x.FundingStreamPeriodCode, OrganisationId = x.OrganisationId, Period = x.Period, PeriodTypeCode = x.PeriodTypeCode, UopCode = x.UoPCode, Id = x.ID, }) .OrderBy(x => x.Id); result = await PaginatedResultFactory <SummarisedActualDto> .CreatePaginatedResultAsync(data, pageSize, pageNumber, cancellationToken); } return(result); }
public async Task <PaginatedResult <Trade> > GetTradesAsync(string productId, int?after = null, CancellationToken cancellationToken = default) { using var client = _factory.CreateClient(ClientNames.MarketData); var requestUriBuilder = new StringBuilder($"/products/{productId}/trades"); var queryString = HttpUtility.ParseQueryString(string.Empty); if (after.HasValue) { queryString.Add("after", $"{after.Value}"); } if (queryString.HasKeys()) { requestUriBuilder.Append($"?{queryString}"); } var response = await client.GetAsync(requestUriBuilder.ToString(), cancellationToken); response.EnsureSuccessStatusCode(); var trades = await JsonSerializer.DeserializeAsync <IReadOnlyCollection <Trade> >(await response.Content.ReadAsStreamAsync(cancellationToken), _options, cancellationToken); return(PaginatedResultFactory.Create(response.Headers, trades)); }
public async Task <PaginatedResult <Order>?> ListOrdersAsync(CancellationToken cancellationToken = default) { using var client = _factory.CreateClient(ClientNames.TradingClient); var response = await client.GetAsync(new Uri("/orders", UriKind.Relative), cancellationToken); response.EnsureSuccessStatusCode(); var json = await response.Content.ReadAsStringAsync(cancellationToken); return(PaginatedResultFactory.Create(response.Headers, JsonSerializer.Deserialize <IReadOnlyCollection <Order> >(json, _serializerOptions))); }
public async Task <IPaginatedResult <int> > GetSubmittingProviders(CancellationToken cancellationToken, DateTime?startDateTime = null, int pageSize = 0, int pageNumber = 0) { IPaginatedResult <int> providers; using (var context = _ilr1920RulebaseContext()) { var query = GetSubmittedProviders(context, startDateTime); providers = await PaginatedResultFactory <int> .CreatePaginatedResultAsync(query, pageSize, pageNumber, cancellationToken); } return(providers); }
public async Task <IPaginatedResult <Dtos.Learner> > GetLearners( CancellationToken cancellationToken, DateTime?startDateTime = null, int?ukprn = null, int?aimType = null, int?standardCode = null, int[] fundModel = null, int?progType = null, int pageSize = 0, int pageNumber = 0) { List <int> providers = null; IPaginatedResult <Dtos.Learner> learners; if (ukprn.HasValue) { providers = new List <int>() { ukprn.GetValueOrDefault() }; } else { using (var context = _ilr1920RulebaseContext()) { var providersQuery = GetSubmittedProviders(context, startDateTime); providers = await providersQuery.ToListAsync(cancellationToken); } } using (var context = _ilr1920ValidContext()) { var query = context.Learners .Where(x => (providers.Contains(x.UKPRN)) && x.LearningDeliveries != null && (fundModel == null || fundModel.Length == 0 || x.LearningDeliveries.Any(y => fundModel.Contains(y.FundModel))) && x.LearningDeliveries.Any(y => !aimType.HasValue || y.AimType == aimType.Value) && x.LearningDeliveries.Any(z => (standardCode.HasValue && standardCode.Value == -1) || z.StdCode == standardCode) && x.LearningDeliveries.Any(z => (progType.HasValue && progType.Value == -1) || z.ProgType == progType)) .AsQueryable(); var data = ProjectLearners(query); learners = await PaginatedResultFactory <Dtos.Learner> .CreatePaginatedResultAsync(data, pageSize, pageNumber, cancellationToken); } return(learners); }