Exemplo n.º 1
0
        public async Task <IActionResult> GetAllAsync()
        {
            var querySet = _jsonApiBuilder.BuildQuerySet(HttpContext.Request.Query);

            var pagedInvoices = await _invoiceManager.GetAllAsync(querySet);

            var invoiceDtos = _mapper.Map <IEnumerable <InvoiceDto> >(pagedInvoices.Items, opt => opt.Items["include"] = querySet.Include);
            var included    = _includedCollector.CollectIncluded(pagedInvoices.Items, querySet.Include);
            var links       = _jsonApiBuilder.BuildCollectionLinks(HttpContext.Request.Path, querySet, pagedInvoices);
            var meta        = _jsonApiBuilder.BuildCollectionMetadata(pagedInvoices);

            return(Ok(new ResourceResponse()
            {
                Meta = meta, Links = links, Data = invoiceDtos, Included = included
            }));
        }
        public async Task <IActionResult> GetAllAsync()
        {
            var querySet = _jsonApiBuilder.BuildQuerySet(HttpContext.Request.Query);

            var pagedAccountancyExports = await _accountancyExportManager.GetAllAsync(querySet);

            var accountancyExportDtos = _mapper.Map <IEnumerable <AccountancyExportDto> >(pagedAccountancyExports.Items);
            var links = _jsonApiBuilder.BuildCollectionLinks(HttpContext.Request.Path, querySet, pagedAccountancyExports);
            var meta  = _jsonApiBuilder.BuildCollectionMetadata(pagedAccountancyExports);

            return(Ok(new ResourceResponse()
            {
                Meta = meta, Links = links, Data = accountancyExportDtos
            }));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> GetOutstandingJobs()
        {
            var querySet = _jsonApiBuilder.BuildQuerySet(HttpContext.Request.Query);

            var pagedOutstandingJobs = await _reportManager.GetOutstandingJobs(querySet);

            var outstandingJobDtos = _mapper.Map <IEnumerable <OutstandingJobDto> >(pagedOutstandingJobs.Items);
            var links = _jsonApiBuilder.BuildCollectionLinks(HttpContext.Request.Path, querySet, pagedOutstandingJobs);
            var meta  = _jsonApiBuilder.BuildCollectionMetadata(pagedOutstandingJobs);

            return(Ok(new ResourceResponse()
            {
                Meta = meta, Links = links, Data = outstandingJobDtos
            }));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> GetRelatedTelephonesByIdAsync(int buildingId)
        {
            var querySet = _jsonApiBuilder.BuildQuerySet(HttpContext.Request.Query);

            querySet.Include.Fields = new string[] { "country", "telephone-type" };

            var pagedTelephones = await _telephoneManager.GetAllByBuildingIdAsync(buildingId, querySet);

            var telephoneDtos = _mapper.Map <IEnumerable <TelephoneDto> >(pagedTelephones.Items, opt => opt.Items["include"] = querySet.Include);
            var included      = _includedCollector.CollectIncluded(pagedTelephones.Items, querySet.Include);
            var links         = _jsonApiBuilder.BuildCollectionLinks(HttpContext.Request.Path, querySet, pagedTelephones);
            var meta          = _jsonApiBuilder.BuildCollectionMetadata(pagedTelephones);

            return(Ok(new ResourceResponse()
            {
                Meta = meta, Links = links, Data = telephoneDtos, Included = included
            }));
        }