public IHttpActionResult PutTicketCategory(int id, TicketCategory ticketCategory) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != ticketCategory.TicketCategoryID) { return BadRequest(); } db.Entry(ticketCategory).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TicketCategoryExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostTicketCategory(TicketCategory ticketCategory) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.TicketCategories.Add(ticketCategory); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = ticketCategory.TicketCategoryID }, ticketCategory); }