public IHttpActionResult PutTestimonial(int id, Testimonial testimonial) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != testimonial.ID) { return BadRequest(); } db.Entry(testimonial).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TestimonialExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostTestimonial(Testimonial testimonial) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Testimonials.Add(testimonial); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = testimonial.ID }, testimonial); }