BookManagement.Web.Controllers.BookController.Edit C# (CSharp) Method

Edit() private method

private Edit ( Book book, System.Web.HttpPostedFileBase PathImage ) : System.Web.Mvc.ActionResult
book BookManagement.Core.Models.Book
PathImage System.Web.HttpPostedFileBase
return System.Web.Mvc.ActionResult
        public ActionResult Edit(Book book, HttpPostedFileBase PathImage)
        {
            if (ModelState.IsValid)
            {
                if ((PathImage != null && PathImage.ContentLength > 0))
                {
                    var fileName = Path.GetFileName(PathImage.FileName);
                    var imageName = "book" + db.Books.Select(b => b.Id).Max() + ".jpg";
                    var path = Path.Combine(Server.MapPath("~/Images"), imageName);
                    PathImage.SaveAs(path);

                    book.PathImage = "/Images/" + imageName;
                }

                db.Entry(book).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.Categories = db.Categories.ToList();
            return View(book);
        }

Same methods

BookController::Edit ( int id ) : System.Web.Mvc.ActionResult