public ActionResult Create([Bind(Include = "AuthorId,Name")] Authors authors)
        {
            if (ModelState.IsValid)
            {
                db.Authors.Add(authors);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(authors));
        }
        public ActionResult Create([Bind(Include = "GenreId,Genre")] Genres genres)
        {
            if (ModelState.IsValid)
            {
                db.Genres.Add(genres);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(genres));
        }
        public ActionResult Donate([Bind(Include = "Id,Title,ISBN, Image, QtyAvailable,GenreId,AuthorId")] Books books)
        {
            if (ModelState.IsValid)
            {
                var rec = db.Books.Where(b => b.ISBN == books.ISBN).FirstOrDefault();

                if (rec != null)  //book exists
                {
                    rec.QtyAvailable   -= books.QtyAvailable;
                    db.Entry(rec).State = EntityState.Modified;
                }
                else
                {
                    db.Books.Add(books);
                }
            }

            db.SaveChanges();

            ViewBag.AuthorName = db.Authors.Find(books.AuthorId).Name;
            ViewBag.GenreName  = db.Genres.Find(books.GenreId).Genre;

            return(View("DonateReceipt", books));
        }
        public int UploadImageInDataBase(HttpPostedFileBase file, DonateBookVM donateBookVM)
        {
            donateBookVM.Image = ConvertToBytes(file);


            var books = new Books
            {
                Image = donateBookVM.Image,
            };



            int i = db.SaveChanges();

            if (i == 1)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }