public IHttpActionResult PutComp(int id, Competition competition) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != competition.ID) { return(BadRequest("No Competition exists with that ID")); } // commented line for unit tests and added the mark as modified, reverse before deploying //db.MarkAsModified(competition); db.Entry(competition).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CompetitionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutGolfer(int id, Golfer golfer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != golfer.ID) { return(BadRequest("Golfer with ID doesn't exist")); } // commented line for unit tests and added the mark as modified, reverse before deploying db.Entry(golfer).State = EntityState.Modified; //db.MarkAsModified(golfer); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GolferExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "ProductID,Name,Price,Quantity,SubDepartment,ItemCategory")] Product product) { if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(product)); }
public ActionResult Edit([Bind(Include = "TournamentID,TournamentName,TournamentDate")] Tournament tournament) { if (ModelState.IsValid) { db.Entry(tournament).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tournament)); }
public ActionResult Edit([Bind(Include = "EventTypeID,Type")] EventType eventType) { if (ModelState.IsValid) { db.Entry(eventType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(eventType)); }
public async Task <Reservation> UpdateReservation(Reservation reservation) { try { reservation = setReservation(reservation); _context.Entry(reservation).State = EntityState.Modified; await _context.SaveChangesAsync(); return(reservation); } catch (Exception ex) { throw ex; } }