public ActionResult Create([Bind(Include = "BookId,Title,Description,Text,Visit,ImageName")] Book book , HttpPostedFileBase imageBook) { if (ModelState.IsValid) { if (imageBook != null && imageBook.IsImage()) { book.ImageName = Guid.NewGuid().ToString() + Path.GetExtension(imageBook.FileName); imageBook.SaveAs(Server.MapPath("/Content/Image/Book/" + book.ImageName)); ImageResizer img = new ImageResizer(); img.Resize(Server.MapPath("/Content/Image/Book/" + book.ImageName), Server.MapPath("/Content/Image/Book/Thumbnail/" + book.ImageName)); book.CreateDate = DateTime.Now; _bookBusiness.Insert(book); _bookBusiness.Save(); return(RedirectToAction("Index")); } return(View(book)); } return(View(book)); }
/// <summary> /// Inseri um livro chamando a camada de business /// </summary> /// <param name="book">Livro que será inserido</param> /// <returns>Livro inserido</returns> public BookModel Insert(BookModel book) { return(_bookBusiness.Insert(book)); }
public void Insert([FromBody] Book value) { _bus.Insert(value); }