예제 #1
0
        public ActionResult UpdateBook(FormCollection collection)
        {
            Book newBook = new Book();

            newBook.BookID    = Int32.Parse(collection["BookID"]);
            newBook.Title     = collection["Title"];
            newBook.Synopsis  = collection["Synopsis"];
            newBook.Publisher = collection["Publisher"];
            newBook.Category  = collection["Category"];
            newBook.Price     = Int32.Parse(collection["Price"]);
            newBook.Stock     = Int32.Parse(collection["Stock"]);
            newBook.Discount  = (double.Parse(collection["Discount"])) / 100;
            newBook.SubStatus = Convert.ToBoolean(collection["SubStatus"]);
            newBook.Authors   = collection["Authors"].Split(',').ToList();
            newBook.Genres    = collection["Genres"].Split(',').ToList();


            if (BookCRUD.UpdateBook(newBook))
            {
                return(Content("<script>alert('Book has been Updated Successfully.');window.location.href=document.referrer;</script>"));
            }
            else
            {
                return(Content("<script>alert('Book could not be Update.');window.location.href=document.referrer</script>"));
            }
        }