示例#1
0
        public ActionResult Edit(int ID, string Name, string PublishingCompany,
                                 DateTime PublishingDate, string Size, int NumberOfPages, string CoverType,
                                 int BookTypeID, int AuthorID, double Price, HttpPostedFileBase file, int Discount)
        {
            Book book = new Book
            {
                AuthorCollection   = AuthorAction.ListAuthor(),
                BookTypeCollection = BookAction.ListBookType()
            };

            ViewBag.book = BookAction.FindBook(ID);
            try
            {
                string _path = "";
                if (file.ContentLength > 0)
                {
                    string _FileName = Path.GetFileName(file.FileName);
                    _path = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName);
                    file.SaveAs(_path);
                    BookAction.EditFullBook(ID, Name, PublishingCompany, PublishingDate, Size,
                                            NumberOfPages, CoverType, BookTypeID, AuthorID, _FileName, Price, Discount);
                }
                ViewBag.Message = "Updated Successfully";
                return(View(book));
            }
            catch
            {
                ViewBag.Message = "Updated Fail!";
                return(View(book));
            }
        }
        public ActionResult Detail(int ID)
        {
            Book book = BookAction.FindBook(ID);

            ViewBag.Book = book;
            return(View());
        }
示例#3
0
 public ActionResult AddCount(int ID, int Count)
 {
     ViewBag.Book = BookAction.FindBook(ID);
     if (BookAction.AddCount(ID, Count))
     {
         ViewBag.Book = BookAction.FindBook(ID);
         return(RedirectToAction("AddCount", new { ID }));
     }
     return(RedirectToAction("AddCount", new { ID }));
 }
示例#4
0
        public ActionResult Edit(int ID)
        {
            ViewBag.book = BookAction.FindBook(ID);
            Book book = new Book();

            using (var db = new BookContext())
            {
                book.AuthorCollection   = db.Authors.ToList();
                book.BookTypeCollection = db.BookTypes.ToList();
            }
            return(View(book));
        }
示例#5
0
        public ActionResult Detail(int ID)
        {
            Book book = BookAction.FindBook(ID);

            if (Session["UserName"] != null)
            {
                int id_account = (int)Session["UserID"];
                BookAction.Watched(id_account, ID);
            }
            else
            {
                BookAction.Watched(null, ID);
            }
            ViewBag.Book     = book;
            ViewBag.ListBook = BookAction.ListBook();
            return(View());
        }
示例#6
0
 public ActionResult AddCount(int ID)
 {
     ViewBag.Book = BookAction.FindBook(ID);
     return(View());
 }