Exemplo n.º 1
0
        /// <summary>
        /// Creation of a TraineeshipPayment ressource Uri
        /// </summary>
        /// <param name="options">options as TraineeshipPaymentSSFP</param>
        /// <param name="type">type as RessourceUriType</param>
        /// <returns>An url of type IUrlHelper</returns>
        private string CreateTraineeshipPaymentsRessourceUri(TraineeshipPaymentSSFP options, RessourceUriType type)
        {
            switch (type)
            {
            case RessourceUriType.PreviousPage:
                return(Url.Link("GetAllTraineeshipPaymentsAsync",
                                new
                {
                    PageNumber = options.PageNumber - 1,
                    options.PageSize,
                    options.SortBy,
                    options.FilterBy
                }));

            case RessourceUriType.NextPage:
                return(Url.Link("GetAllTraineeshipPaymentsAsync",
                                new
                {
                    PageNumber = options.PageNumber + 1,
                    options.PageSize,
                    options.SortBy,
                    options.FilterBy
                }));

            default:
                return(Url.Link("GetAllTraineeshipPaymentsAsync",
                                new
                {
                    options.PageNumber,
                    options.PageSize,
                    options.SortBy,
                    options.FilterBy
                }));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult <IReadOnlyCollection <TraineeshipPaymentDto> > > GetAllTraineeshipPaymentAsync([FromQuery] TraineeshipPaymentSSFP options)
        {
            var traineeshipPayments = await _traineeshipPaymentService.GetAllTraineeshipPaymentAsync(options);

            if (traineeshipPayments == null)
            {
                return(NotFound("Nothing found."));
            }

            var previousPageLink = options.HasPrevious ? CreateTraineeshipPaymentsRessourceUri(options, RessourceUriType.PreviousPage) : null;
            var nextPageLink     = options.HasNext ? CreateTraineeshipPaymentsRessourceUri(options, RessourceUriType.NextPage) : null;

            var paginationMetada = new
            {
                options.TotalCount,
                options.PageSize,
                options.PageNumber,
                options.TotalPages,
                options.FilterBy,
                options.SortBy,
                options.UserInput,
                previousPageLink,
                nextPageLink
            };

            Response.Headers.Add("X-Pagination", JsonSerializer.Serialize(paginationMetada));

            return(Ok(traineeshipPayments));
        }
Exemplo n.º 3
0
        /// <inheritdoc/>
        public async Task <IReadOnlyCollection <TraineeshipPaymentDto> > GetAllTraineeshipPaymentAsync(TraineeshipPaymentSSFP options)
        {
            var traineeshipPayments = _paraContext.TraineeshipPayments
                                      .SearchTraineeshipPaymentBy(options)
                                      .AsNoTracking()
                                      .SortTraineeshipPaymentBy(options.SortBy)
                                      .FilterTraineeshipPaymentBy(options.FilterBy, options)
                                      .Select(p => new TraineeshipPaymentDto
            {
                PilotId       = p.PilotID,
                TraineeshipID = p.TraineeshipID,
                PaymentDate   = p.PaymentDate,
                IsPaid        = p.IsPaid
            });

            options.SetPagingValues(traineeshipPayments);

            var pagedQuery = traineeshipPayments.Page(options.PageNumber - 1, options.PageSize);



            return(await pagedQuery.ToListAsync());
        }