public Book UpdateBook(Book _book)
        {
            try
            {
                using (var context = new LibrarySystemEntities())
                {
                    context.Configuration.ProxyCreationEnabled = false;
                    Book oldbook = context.Books.FirstOrDefault(c => c.BookId == _book.BookId);
                    if (oldbook != null)
                    {
                        oldbook.BookName = _book.BookName;
                        oldbook.BookPages = _book.BookPages;
                        oldbook.BookPrice = _book.BookPrice;
                        oldbook.CategoryId = _book.CategoryId;

                        context.SaveChanges();
                        return oldbook;
                    }
                    return null;
                }
            }
            catch (Exception)
            {

                throw;
            }

        }
        public MethodResponse UpdateBookForWCF(Book _book)
        {
            MethodResponse methodresponse = new MethodResponse();
            try
            {
                Book lastbook = UpdateBook(_book);
                methodresponse.Type = MethodResponse.ResponseType.Succeed;
                methodresponse.ResultText = "Book Updated";
                methodresponse.Object = lastbook;
            }
            catch (Exception ex)
            {
                CustomException custom_exception = new CustomException()
                {
                    Exception = ex,
                    ExceptionTime = DateTime.Now,
                    Parameters = "",
                    HelpLink = "",
                    User = "",
                    MethodName = "UpdateBookForWCF"
                };
                CustomExceptionDB custom_exceptionDB = new CustomExceptionDB();
                bool isSaved = custom_exceptionDB.SaveException(custom_exception);
                if (isSaved == true)
                {
                    //..
                }
                methodresponse.Object = null;
                methodresponse.Type = MethodResponse.ResponseType.Error;
                methodresponse.ResultText = "An Error Occurred While Updating Book";



            }
            return methodresponse;
        }
        public Book AddBook(Book _book)
        {
            try
            {
                using (var context = new LibrarySystemEntities())
                {
                    context.Configuration.ProxyCreationEnabled = false;
                    context.Books.Add(_book);

                    context.SaveChanges();
                    return _book;
                }
            }
            catch (Exception)
            {

                throw;
            }
        }