Example #1
0
        public ActionResult Create(Pdtable pdtable, HttpPostedFileBase file)
        {
            if (ModelState.IsValid && file != null && file.ContentLength > 0)
            {
                churchdbEntities4 db = new churchdbEntities4();
                string PdfName = System.IO.Path.GetFileName(file.FileName);
                string physicalPath = Server.MapPath("~/Puploads/" + PdfName);

                // save image in folder
                file.SaveAs(physicalPath);
                Pdtable newRecord = new Pdtable();
                newRecord.pname = Request.Form["pname"];
                newRecord.pdate = Request.Form["pdate"];
                newRecord.pdfdoc = "~/Puploads/" + PdfName;
                db.Pdtables.Add(newRecord);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(pdtable);
        }
Example #2
0
 //
 // GET: /Pdf/
 public ActionResult Index(int page = 1)
 {
     churchdbEntities4 db = new churchdbEntities4();
     return View(db.Pdtables.OrderByDescending(v => v.pid).ToPagedList(page, 3));
 }