Exemplo n.º 1
0
        public ActionResult DisplayPDF(int id)
        {
            var cont   = new BlueprintMediaServisEntities1();
            var query  = cont.Magazines.ToList();
            var result = query.Where(m => m.id == id).ToList();

            //var query = from magazine in BMSentity.Magazines where (magazine.id == id) select magazine.pdfFile;
            byte[]       byteArray = result.Select(m => m.pdfFile).First();
            MemoryStream pdfStream = new MemoryStream();

            pdfStream.Write(byteArray, 0, byteArray.Length);
            pdfStream.Position = 0;
            return(new FileStreamResult(pdfStream, "application/pdf"));
        }
Exemplo n.º 2
0
        public ActionResult Insert(Magazine magazineEntity, HttpPostedFileBase image, HttpPostedFileBase pdf)
        {
            string imagePath = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(image.FileName));
            string pdfPath   = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(pdf.FileName));

            using (BlueprintMediaServisEntities1 entities = new BlueprintMediaServisEntities1())
            {
                magazineEntity.imageFile  = ConvertByte(imagePath, image);
                magazineEntity.pdfFile    = ConvertByte(pdfPath, pdf);
                magazineEntity.updateTime = DateTime.Now;
                magazineEntity.createTime = DateTime.Now;

                entities.Magazines.Add(magazineEntity);
                entities.SaveChanges();
            }

            return(Redirect(Request.UrlReferrer.ToString()));
        }
Exemplo n.º 3
0
        public ActionResult Index()
        {
            BlueprintMediaServisEntities1 BMSentity = new BlueprintMediaServisEntities1();

            return(View(Tuple.Create <Magazine, IEnumerable <Magazine> >(new Magazine(), BMSentity.Magazines.ToList())));
        }