Example #1
0
        public ActionResult ListAllLastProductsSoldFile()
        {
            try
            {
                ICollection <FileInfo> files = FilesDownload.GetDirectoryProductsSoldList().GetFiles();

                if (files.Count < 1)
                {
                    log.Info("User tried to access to an empty folder of daily products sold file");
                    return(View("FileNotFound"));
                }

                return(View(FilesDownload.GetListFilesNames(files)));
            }

            catch (Exception ex)
            {
                log.Error("Could't get list of daily products sold file", ex);
                return(View("ErrorDownload"));
            }
        }
Example #2
0
        public ActionResult DownloadProductsSoldFile(string fileName)
        {
            FileInfo file = FilesDownload.GetDirectoryProductsSoldList().GetFiles().Where(x => x.Name == fileName).FirstOrDefault();

            if (file != null)
            {
                try
                {
                    string filePath    = file.FullName;
                    string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                    return(File(filePath, contentType, Path.GetFileName(filePath)));
                }
                catch (Exception ex)
                {
                    log.Error("Could't download daily products sold file", ex);
                    return(View("ErrorDownload"));
                }
            }

            log.Info("The daily products sold file doesn't exist");
            return(View("FileNotFound"));
        }