public IHttpActionResult Post(int id, Listing updates) { updates.id = id; if (ModelState.IsValid) { updates.id = id; if (_repo.Update(updates)) { return Ok(); } return InternalServerError(); } return BadRequest(ModelState); }
public IHttpActionResult Post(Listing newListing) { if (ModelState.IsValid) { _repo.Add(newListing); _repo.SaveChanges(); if (_repo.Get(newListing.id) != null) { return Created("/api/listings/" + newListing.id, newListing); } return InternalServerError(); } return BadRequest(ModelState); }