//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 { //Stages _repo.Add(newListing); //Commits _repo.SaveChanges(); return Created("/api/listings/" + newListing.Id, newListing); } catch { return InternalServerError(); } } return BadRequest(ModelState); }