示例#1
0
        public async Task <IActionResult> GetLifeCyclePhase(
            [FromServices] BackofficeContext context,
            [FromRoute] string id,
            [FromRoute] int faseId,
            CancellationToken cancellationToken = default)
        {
            var projectionPosition = await context.GetProjectionPositionAsync(nameof(PublicServiceLifeCycleListProjections), cancellationToken);

            Response.Headers.Add(PublicServiceHeaderNames.LastObservedPosition, projectionPosition.ToString());

            var publicService =
                await context
                .PublicServiceLifeCycleList
                .AsNoTracking()
                .SingleOrDefaultAsync(item => item.PublicServiceId == id && item.LifeCycleStageId == faseId, cancellationToken);

            if (publicService == null)
            {
                return(NotFound());
            }

            return(Ok(
                       new LifeCycleStageResponse(
                           publicService.LifeCycleStageType,
                           PublicServiceRegistry.LifeCycleStageType.Parse(publicService.LifeCycleStageType).Translation.Name,
                           publicService.From,
                           publicService.To)));
        }
示例#2
0
        public async Task <IActionResult> GetLifeCyclePhase(
            [FromServices] BackofficeContext context,
            [FromRoute] string id,
            [FromRoute] int faseId,
            CancellationToken cancellationToken = default)
        {
            var projectionPosition = await context.GetProjectionPositionAsync(typeof(PublicServiceLifeCycleListProjections), cancellationToken);

            Response.Headers.Add(PublicServiceHeaderNames.LastObservedPosition, projectionPosition.ToString());

            await context.CheckPublicServiceAsync(id, cancellationToken);

            var publicServiceLifeCycleItem =
                await context
                .PublicServiceLifeCycleList
                .AsNoTracking()
                .SingleOrDefaultAsync(item => item.PublicServiceId == id && item.LifeCycleStageId == faseId, cancellationToken);

            if (publicServiceLifeCycleItem == null)
            {
                throw new ApiException("Onbestaande levensloopfase.", StatusCodes.Status404NotFound);
            }

            // TODO: Introduce soft delete for lifecycle
            //if (publicServiceLifeCycleItem.Removed)
            //    throw new ApiException("Levensloopfase werd verwijderd.", StatusCodes.Status410Gone);

            return(Ok(
                       new LifeCycleStageResponse(
                           publicServiceLifeCycleItem.LifeCycleStageType,
                           PublicServiceRegistry.LifeCycleStageType.Parse(publicServiceLifeCycleItem.LifeCycleStageType).Translation.Name,
                           publicServiceLifeCycleItem.From,
                           publicServiceLifeCycleItem.To)));
        }
        public async Task <IActionResult> Get(
            [FromServices] BackofficeContext context,
            [FromRoute] string id,
            CancellationToken cancellationToken = default)
        {
            var projectionPosition = await context.GetProjectionPositionAsync(cancellationToken);

            Response.Headers.Add(PublicServiceHeaderNames.LastObservedPosition, projectionPosition.ToString());

            var publicService =
                await context
                .PublicServiceList
                .AsNoTracking()
                .SingleOrDefaultAsync(item => item.PublicServiceId == id, cancellationToken);

            if (publicService == null)
            {
                return(NotFound());
            }

            return(Ok(
                       new PublicServiceResponse(
                           publicService.PublicServiceId,
                           publicService.Name,
                           publicService.CompetentAuthorityCode,
                           publicService.CompetentAuthorityName,
                           publicService.ExportToOrafin,
                           publicService.CurrentLifeCycleStageType,
                           !string.IsNullOrEmpty(publicService.CurrentLifeCycleStageType)
                        ? PublicServiceRegistry.LifeCycleStageType.Parse(publicService.CurrentLifeCycleStageType).Translation.Name
                        : string.Empty,
                           publicService.IpdcCode,
                           publicService.LegislativeDocumentId)));
        }
        public async Task <IActionResult> List(
            [FromServices] BackofficeContext context,
            CancellationToken cancellationToken = default)
        {
            var filtering  = Request.ExtractFilteringRequest <PublicServiceListItemFilter>();
            var sorting    = Request.ExtractSortingRequest();
            var pagination = Request.ExtractPaginationRequest();

            var pagedOrganisations =
                new PublicServiceListQuery(context)
                .Fetch(filtering, sorting, pagination);

            Response.AddPagedQueryResultHeaders(pagedOrganisations);

            var projectionPosition = await context.GetProjectionPositionAsync(cancellationToken);

            Response.Headers.Add(PublicServiceHeaderNames.LastObservedPosition, projectionPosition.ToString());

            return(Ok(await pagedOrganisations.Items.ToListAsync(cancellationToken)));
        }
示例#5
0
        public async Task <IActionResult> ListLifeCycleStages(
            [FromServices] BackofficeContext context,
            [FromRoute] string id,
            CancellationToken cancellationToken = default)
        {
            var projectionPosition = await context.GetProjectionPositionAsync(nameof(PublicServiceLifeCycleListProjections), cancellationToken);

            Response.Headers.Add(PublicServiceHeaderNames.LastObservedPosition, projectionPosition.ToString());

            // idea: if dienstverleningid does not exist => 404 + documentatie aanpassen swagger

            var filter     = Request.ExtractFilteringRequest <LifeCycleFilter>();
            var sorting    = Request.ExtractSortingRequest();
            var pagination = Request.ExtractPaginationRequest();

            var pagedLifeCycle =
                new LifeCycleQuery(context, id)
                .Fetch(filter, sorting, pagination);

            Response.AddPagedQueryResultHeaders(pagedLifeCycle);

            return(Ok(await pagedLifeCycle.Items.ToListAsync(cancellationToken)));
        }
 public static Task <long> GetProjectionPositionAsync(this BackofficeContext context, CancellationToken cancellationToken)
 => context.GetProjectionPositionAsync(PublicServiceBackofficeRunner.Name, cancellationToken);