public async Task <IActionResult> PutHero([FromRoute] int id, [FromBody] Hero hero) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != hero.ID) { return(BadRequest()); } _context.Entry(hero).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HeroExists(id)) { return(NotFound()); } else { throw; } } return(Ok(hero)); }
public ActionResult Edit([Bind(Include = "ID,GoatID,CustomerID,GoatName,CustomerFirst,CustomerLast,LotAddress,LotDescription")] Lot lot) { if (ModelState.IsValid) { db.Entry(lot).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(lot)); }
public ActionResult Edit([Bind(Include = "ItemID,ItemName,ItemDescription,SellerID")] Item item) { if (ModelState.IsValid) { db.Entry(item).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SellerID = new SelectList(db.Sellers, "SellerID", "Sellername", item.SellerID); return(View(item)); }
public ActionResult Edit([Bind(Include = "ID,Title,Start,Duration,Location,PersonID")] Event @event) { if (ModelState.IsValid) { db.Entry(@event).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PersonID = new SelectList(db.Persons, "ID", "Name", @event.PersonID); return(View(@event)); }
public ActionResult Edit([Bind(Include = "ID,Timestamp,EventID,PersonID")] RSVP rSVP) { if (ModelState.IsValid) { db.Entry(rSVP).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EventID = new SelectList(db.Events, "ID", "Title", rSVP.EventID); ViewBag.PersonID = new SelectList(db.Persons, "ID", "Name", rSVP.PersonID); return(View(rSVP)); }
public ActionResult Edit([Bind(Include = "ID,Name,BirthDate,BirthCity")] Artists artists) { try { if (ModelState.IsValid) { db.Entry(artists).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(artists)); }
public ActionResult Edit([Bind(Include = "ID,ArtWorkID,GenreID")] Classifications classifications) { try { if (ModelState.IsValid) { db.Entry(classifications).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } ViewBag.ArtWorkID = new SelectList(db.ArtWorks, "ID", "Title", classifications.ArtWorkID); ViewBag.GenreID = new SelectList(db.Genres, "ID", "Name", classifications.GenreID); return(View(classifications)); }