Example #1
0
        public async Task <IActionResult> GujaratSamachar(string city)
        {
            string file, name = $"{DateTime.Now.ToString("ddMMyyyy")}-{city}.pdf";
            bool   result;

            (file, result) = _paperIOService.GetFile(nameof(GujaratSamachar), name);
            if (result)
            {
                return(PhysicalFile(file, "application/pdf", Path.GetFileName(file)));
            }
            else
            {
                var files = await _downloadNewsPaperService.GetGsFilesAsync(city);

                var doc = _pdfService.GetPdfFromImage(files);
                result = false;
                result = _paperIOService.CleanDir(nameof(GujaratSamachar));
                using (var stream = System.IO.File.Create(file))
                {
                    doc.Publish(stream);
                }
                if (result)
                {
                    return(PhysicalFile(file, "application/pdf", Path.GetFileName(file)));
                }
                else
                {
                    return(NotFound());
                }
            }
            // return File(files.ZipIt(), "application/zip", $"{nameof(GujaratSamachar)}-{DateTime.Now.ToString("ddMMyyyy")}.zip");
        }