public ActionResult Edit([Bind(Include = "ID,FirstName,LastName,Age,Image,Specialty")] Author author, HttpPostedFileBase imageUpload) { bool isFileValid = true; if (ModelState.IsValid) { if (imageUpload != null && imageUpload.ContentLength > 0) { if (Utils.SaveImage(imageUpload)) { isFileValid = true; author.Image = imageUpload.FileName; } else { isFileValid = false; ModelState.AddModelError("", "The new author image could not been saved."); } } if (isFileValid) { db.Entry(author).State = EntityState.Modified; if (string.IsNullOrEmpty(author.Image)) { db.Entry(author).Property(p => p.Image).IsModified = false; } db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(author)); }
public ActionResult Edit([Bind(Include = "ID,FirstName,LastName,Email,City,Street,PhoneNumber,BirthDate,CreationDate")] Customer customer) { if (ModelState.IsValid) { db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Edit([Bind(Include = "AuthorId,Name")] Author author) { if (ModelState.IsValid) { db.Entry(author).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(author)); }
public ActionResult Edit([Bind(Include = "BookId,GenreId,AuthorId,Title,Price,BookArtUrl")] Book book) { if (ModelState.IsValid) { db.Entry(book).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(book)); }
public ActionResult Edit([Bind(Include = "GenreId,Name,Description")] Genre genre) { if (ModelState.IsValid) { db.Entry(genre).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(genre)); }
public IActionResult Put(int id, [FromBody] bookLocation bookLocation) { if (!ModelState.IsValid) { return(BadRequest()); } db.Entry(bookLocation).State = EntityState.Modified; db.SaveChanges(); return(AcceptedAtAction("Get", new { id = bookLocation.bookID }, bookLocation)); }
public ActionResult Edit([Bind(Include = "bookStoreNumber,bookID,bookStoreLocation,bookShelve,bookPhysical")] bookLocation bookLocation) { if (ModelState.IsValid) { db.Entry(bookLocation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.bookID = new SelectList(db.bookInfo, "bookID", "bookName", bookLocation.bookID); return(View(bookLocation)); }
public ActionResult Edit([Bind(Include = "BookId,AuthorId,Title,NumOfPages,YearPublished,Price,Description")] Book book) { if (ModelState.IsValid) { db.Entry(book).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AuthorId = new SelectList(db.Authors, "AuthorId", "AuthorName", book.AuthorId); return(View(book)); }
public ActionResult Edit([Bind(Include = "ID,Title,Description,Genre,Price,Image,AuthorID")] Book book, HttpPostedFileBase imageUpload) { bool isFileValid = true; if (ModelState.IsValid) { if (imageUpload != null && imageUpload.ContentLength > 0) { if (Utils.SaveImage(imageUpload)) { isFileValid = true; book.Image = imageUpload.FileName; } else { isFileValid = false; ModelState.AddModelError("", "The new book image could not been saved"); } } if (isFileValid) { db.Entry(book).State = EntityState.Modified; if (string.IsNullOrEmpty(book.Image)) { db.Entry(book).Property(p => p.Image).IsModified = false; } db.SaveChanges(); return(RedirectToAction("Index")); } } ViewBag.AuthorID = new SelectList(db.Authors, "ID", "FirstName", book.AuthorID); return(View(book)); }