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