Exemplo n.º 1
0
        public async Task <ActionResult> DownloadInvoiceFiles(CompetentAuthority authority, Guid id)
        {
            if (authority != CompetentAuthority.England)
            {
                string errorMessage = "Invoice files can only be downloaded for invoice runs related to the Environment Agency.";
                throw new InvalidOperationException(errorMessage);
            }

            FileInfo fileInfo;

            using (IWeeeClient client = weeeClient())
            {
                FetchInvoiceRunIbisZipFile request = new FetchInvoiceRunIbisZipFile(id);
                fileInfo = await client.SendAsync(User.GetAccessToken(), request);
            }

            return(File(fileInfo.Data, "text/plain", fileInfo.FileName));
        }
        public async Task<ActionResult> DownloadInvoiceFiles(CompetentAuthority authority, Guid id)
        {
            if (authority != CompetentAuthority.England)
            {
                string errorMessage = "Invoice files can only be downloaded for invoice runs related to the Environment Agency.";
                throw new InvalidOperationException(errorMessage);
            }

            FileInfo fileInfo;
            using (IWeeeClient client = weeeClient())
            {
                FetchInvoiceRunIbisZipFile request = new FetchInvoiceRunIbisZipFile(id);
                fileInfo = await client.SendAsync(User.GetAccessToken(), request);
            }

            return File(fileInfo.Data, "text/plain", fileInfo.FileName);
        }