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