public ActionResult DeleteConfirmed(int id)
        {
            Ebooks_db ebooks_Db = db.Ebooks_db.Find(id);

            db.Ebooks_db.Remove(ebooks_Db);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: Bookcategoryy/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ebooks_db ebooks_Db = db.Ebooks_db.Find(id);

            if (ebooks_Db == null)
            {
                return(HttpNotFound());
            }
            return(View(ebooks_Db));
        }
        public ActionResult Edit(Ebooks_db ebooks, HttpPostedFileBase imagefile, HttpPostedFileBase pdffile)
        {
            var book = db.Ebooks_db.Where(x => x.Ebook_id == ebooks.Ebook_id).FirstOrDefault();

            if (ModelState.IsValid)
            {
                if (!string.IsNullOrEmpty(imagefile != null ? imagefile.FileName : ""))
                {
                    string path = uploadingfile(imagefile);
                    if (path.Equals("-1"))
                    {
                        ViewBag.error = "Image could not be uploaded....";
                    }
                    else
                    {
                        book.Ebook_img = path;
                    }
                }
                if (!string.IsNullOrEmpty(pdffile != null ? pdffile.FileName : ""))
                {
                    string path1 = uploadingpdffile(pdffile);
                    if (path1.Equals("-1"))
                    {
                        ViewBag.error = "pdf could not be uploaded....";
                    }
                    else
                    {
                        book.Ebook_pdffile = path1;
                    }
                }



                book.Ebook_name      = ebooks.Ebook_name;
                book.Ebook_publisher = ebooks.Ebook_publisher;
                book.Ebook_author    = ebooks.Ebook_author;
                book.cat_id          = ebooks.cat_id;

                book.Ebook_edition = ebooks.Ebook_edition;

                db.Entry(book).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(book));
        }
        public ActionResult Create(Tbl_for_Ebooks evm, HttpPostedFileBase imagefile, HttpPostedFileBase pdffile)
        {
            string path1 = uploadingpdffile(pdffile);
            string path  = uploadingfile(imagefile);

            if (path.Equals("-1"))
            {
                ViewBag.error = "Image could not be uploaded....";
            }

            else
            {
                List <Book_categoryy> li3 = db.Book_categoryy.ToList();
                ViewBag.catlist = new SelectList(li3, "cat_id", "cat_name");

                if (Session["mem_id"] != null)
                {
                    evm.mem_id = Convert.ToInt32(Session["mem_id"]);
                }

                List <tbl_member> li4 = db.tbl_member.ToList();
                ViewBag.memlist = new SelectList(li4, "mem_id", "mem_name");


                Ebooks_db ebk = new Ebooks_db();
                ebk.Ebook_name      = evm.Ebook_name;
                ebk.Ebook_publisher = evm.Ebook_publisher;
                ebk.Ebook_author    = evm.Ebook_author;
                ebk.cat_id          = evm.cat_id;
                ebk.Ebook_img       = path;
                ebk.Ebook_pdffile   = path1;
                ebk.Ebook_edition   = evm.Ebook_edition;
                ebk.mem_id          = evm.mem_id;
                db.Ebooks_db.Add(ebk);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View());
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ebooks_db ebooks = db.Ebooks_db.Find(id);

            if (ebooks == null)
            {
                return(HttpNotFound());
            }
            List <Book_categoryy> li3 = db.Book_categoryy.ToList();

            ViewBag.catlist = new SelectList(li3, "cat_id", "cat_name");



            List <tbl_member> li4 = db.tbl_member.ToList();

            ViewBag.venlist = new SelectList(li4, "mem_id", "mem_name");
            return(View(ebooks));
        }