public ActionResult EditBook(Book u)
 {
     if (ModelState.IsValid)
     {
         BookBL.Update(u);
         return(RedirectToAction("BookB"));
     }
     else
     {
         return(View());
     }
 }
Beispiel #2
0
        public ActionResult Edit(BookViewModel bookViewModel)
        {
            if (book != null)
            {
                var config = new MapperConfiguration(mapping =>
                {
                    mapping.CreateMap <BookViewModel, Book>();
                });
                IMapper mapper    = config.CreateMapper();
                var     book      = mapper.Map <BookViewModel, Book>(bookViewModel);
                var     Categorys = bookBL.BindCategory();
                ViewBag.Mycategory = new SelectList(Categorys, "CategoryId", "CategoryName");
                bookBL.Update(book);

                return(RedirectToAction("BookDetails"));
            }
            return(View());
        }
        protected void gvBookList_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                BookBL bookBL = new BookBL();
                BookBO book   = new BookBO();
                book = GetUpdateObject(book, e.RowIndex);

                bookTable = bookBL.Update(book, bookTable);

                Session[Common.sessionBookList] = bookTable;
                gvBookList.EditIndex            = -1;
                FillGrid();
                lblSuccessMessage.Text = Common.msgUpdateSuccess;
            }
            catch (Exception ex)
            {
                lblErrorMessage.Text = Common.msgUpdateFailure;
            }
        }