public IHttpActionResult PutLocations(int id, Locations locations) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != locations.LocationId) { return BadRequest(); } db.Entry(locations).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LocationsExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostLocations(Locations locations) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Locations.Add(locations); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = locations.LocationId }, locations); }