Esempio n. 1
0
        public async Task <ActionResult <InvitationsResult> > GetInvitations(
            [FromHeader(Name = CurrentPlantMiddleware.PlantHeader)]
            [Required]
            string plant,
            [FromQuery] FilterDto filter,
            [FromQuery] SortingDto sorting,
            [FromQuery] PagingDto paging)
        {
            var query = CreateGetInvitationsQuery(filter, sorting, paging);

            var result = await _mediator.Send(query);

            return(this.FromResult(result));
        }
Esempio n. 2
0
        public async Task <ActionResult> ExportInvitationsToExcel(
            [FromHeader(Name = CurrentPlantMiddleware.PlantHeader)]
            [Required]
            string plant,
            [FromQuery] FilterDto filter,
            [FromQuery] SortingDto sorting)
        {
            var query = CreateGetInvitationsForExportQuery(filter, sorting);

            var result = await _mediator.Send(query);

            if (result.ResultType != ResultType.Ok)
            {
                return(this.FromResult(result));
            }

            var excelMemoryStream = _excelConverter.Convert(result.Data);

            excelMemoryStream.Position = 0;

            return(File(excelMemoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"{_excelConverter.GetFileName()}.xlsx"));
        }
Esempio n. 3
0
        private static GetInvitationsForExportQuery CreateGetInvitationsForExportQuery(FilterDto filter, SortingDto sorting)
        {
            var query = new GetInvitationsForExportQuery(
                filter.ProjectName,
                new Sorting(sorting.Direction, sorting.Property),
                new Filter()
                );

            FillFilterFromDto(filter, query.Filter);

            return(query);
        }
Esempio n. 4
0
        private static GetInvitationsQuery CreateGetInvitationsQuery(FilterDto filter, SortingDto sorting, PagingDto paging)
        {
            var query = new GetInvitationsQuery(
                filter.ProjectName,
                new Sorting(sorting.Direction, sorting.Property),
                new Filter(),
                new Paging(paging.Page, paging.Size)
                );

            FillFilterFromDto(filter, query.Filter);

            return(query);
        }