public IHttpActionResult PutCupcakeVotes(int id, CupcakeVotes cupcakeVotes) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cupcakeVotes.VoteID) { return(BadRequest()); } db.Entry(cupcakeVotes).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CupcakeVotesExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetCupcakeVotes(int id) { CupcakeVotes cupcakeVotes = db.CupcakeVotes.Find(id); if (cupcakeVotes == null) { return(NotFound()); } return(Ok(cupcakeVotes)); }
public IHttpActionResult PostCupcakeVotes(CupcakeVotes cupcakeVotes) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CupcakeVotes.Add(cupcakeVotes); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = cupcakeVotes.VoteID }, cupcakeVotes)); }
public IHttpActionResult DeleteCupcakeVotes(int id) { CupcakeVotes cupcakeVotes = db.CupcakeVotes.Find(id); if (cupcakeVotes == null) { return(NotFound()); } db.CupcakeVotes.Remove(cupcakeVotes); db.SaveChanges(); return(Ok(cupcakeVotes)); }