Exemplo n.º 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));
            }
        }