Ejemplo n.º 1
0
        public async Task <LatestUploadReport> GetLatestUploadsReport(int value, ReportUnit unit)
        {
            if (value == 0)
            {
                throw new ArgumentException("value must be greater than zero.");
            }

            LatestUploadReport report = new LatestUploadReport();

            Task <IEnumerable <DocumentInfo> > uploadsTask = null;

            switch (unit)
            {
            case ReportUnit.Units:
                uploadsTask = _repository.GetLastNItemsAsync(value);
                break;

            case ReportUnit.Hours:
                uploadsTask = _repository.GetItemsInLastNHoursAsync(value);
                break;
            }

            Task <IEnumerable <LatestUploadReportEntry> > reportTask = _repository.GenerateStorageReport();

            await Task.WhenAll(uploadsTask, reportTask);

            report.Uploads           = uploadsTask.Result;
            report.StorageByCategory = reportTask.Result;

            return(report);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <LatestUploadReport> > GetLatestUploads([FromQuery] ReportRequest reportRequest)
        {
            if (!IsReportRequestValid(reportRequest))
            {
                return(BadRequest("document data incomplete"));
            }

            LatestUploadReport report = await _manager.GetLatestUploadsReport(reportRequest.Quantity, reportRequest.Unit);

            return(Ok(report));
        }