Ejemplo n.º 1
0
        public ActionResult Download(int?id, Transaction transaction)
        {
            string contentType = string.Empty;
            String path        = null;
            var    list        = db.Transactions.ToList();

            foreach (var item in list)
            {
                if (item.TransactionId == id)
                {
                    path = item.SlipPath;
                }
            }
            int    CurrentFileID   = Convert.ToInt32(Session["ProjId"]);
            var    filesCol        = obj.GetSlip();
            String CurrentFileName = "";

            foreach (var item in filesCol)
            {
                if (item.SlipPath.Equals(path))
                {
                    CurrentFileName = item.SlipPath;
                }

                if (CurrentFileName.Contains(".pdf"))
                {
                    contentType = "application/pdf";
                }
                if (CurrentFileName.Contains(".txt"))
                {
                    contentType = "application/txt";
                }

                else if (CurrentFileName.Contains(".docx"))
                {
                    contentType = "application/docx";
                }
            }
            String fileName = Path.GetFileName(CurrentFileName);

            return(File(CurrentFileName, contentType, fileName));
        }