public Book GetBookById(int Id)
 {
     Book _objBook = new Book();
     using (var db = new BookContext())
     {
         _objBook = db.Books.Find(Id);
     }
        return _objBook;
 }
        public bool Edit(Book book)
        {
            Boolean res = false;
            using (var db = new BookContext())
            {
               db.Entry(book).State = System.Data.EntityState.Modified;
               db.SaveChanges();
               res = true;

            }
            return res;
        }
        public bool Add(Book book)
        {
            Boolean res = false;
            using (var db = new BookContext())
            {
                    db.Books.Add(book);
                    db.SaveChanges();
                    res = true;

            }
            return res;
        }
 public ActionResult DeleteBook(int Id = 0)
 {
     Book book = new Book();
     if (Id == 0)
     {
         ModelState.Clear();
         book = null;
     }
     else
     {
         book = _bookServices.GetBookById(Id);
     }
     return View(book);
 }
 public ActionResult AddEditBook(Book book)
 {
     Boolean res=false;
     if (book.BookId == 0)
     {
         res=_bookServices.Add(book);
     }
     else
     {
         res = _bookServices.Edit(book);
     }
     if (res == true)
     {
         return RedirectToAction("Index");
     }
     else
     {
         return View();
     }
     //return View();
 }
 public ActionResult DeleteBook(Book book)
 {
     Boolean res = false;
     if (book.BookId != 0)
     {
         res = _bookServices.Delete(book);
     }
     if (res == true)
     {
         return RedirectToAction("Index");
     }
     else
     {
         return View();
     }
     //return View();
 }