public async Task <IActionResult> Sync( [FromServices] IConfiguration configuration, [FromServices] LegacyContext context, [FromServices] IOptions <ResponseOptions> responseOptions, CancellationToken cancellationToken = default) { var filtering = Request.ExtractFilteringRequest <StreetNameSyndicationFilter>(); var sorting = Request.ExtractSortingRequest(); var pagination = Request.ExtractPaginationRequest(); var lastFeedUpdate = await context .StreetNameSyndication .AsNoTracking() .OrderByDescending(item => item.Position) .Select(item => item.SyndicationItemCreatedAt) .FirstOrDefaultAsync(cancellationToken); if (lastFeedUpdate == default) { lastFeedUpdate = new DateTimeOffset(2020, 1, 1, 0, 0, 0, TimeSpan.Zero); } var pagedStreetNames = new StreetNameSyndicationQuery( context, filtering.Filter?.Embed) .Fetch(filtering, sorting, pagination); return(new ContentResult { Content = await BuildAtomFeed(lastFeedUpdate, pagedStreetNames, responseOptions, configuration), ContentType = MediaTypeNames.Text.Xml, StatusCode = StatusCodes.Status200OK }); }
public async Task <IActionResult> Sync( [FromServices] IConfiguration configuration, [FromServices] LegacyContext context, [FromServices] IOptions <ResponseOptions> responseOptions, CancellationToken cancellationToken = default) { var filtering = Request.ExtractFilteringRequest <StreetNameSyndicationFilter>(); var sorting = Request.ExtractSortingRequest(); var pagination = Request.ExtractPaginationRequest(); var pagedStreetNames = new StreetNameSyndicationQuery( context, filtering.Filter?.ContainsEvent ?? false, filtering.Filter?.ContainsObject ?? false) .Fetch(filtering, sorting, pagination); Response.AddPaginationResponse(pagedStreetNames.PaginationInfo); Response.AddSortingResponse(sorting.SortBy, sorting.SortOrder); return(new ContentResult { Content = await BuildAtomFeed(pagedStreetNames, responseOptions, configuration), ContentType = MediaTypeNames.Text.Xml, StatusCode = StatusCodes.Status200OK }); }