// PUT api/Admin/5 public IHttpActionResult PutPhoto(int id, Photo photo) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != photo.Id) { return BadRequest(); } data.Photos.Update(photo); try { data.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PhotoExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostPhoto(Photo photo) { if (!ModelState.IsValid) { return BadRequest(ModelState); } data.Photos.Add(photo); data.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = photo.Id }, photo); }