public async Task <IHttpActionResult> PutInnerCity(int id, InnerCity innerCity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != innerCity.Id) { return(BadRequest()); } db.Entry(innerCity).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InnerCityExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetInnerCity(int id) { InnerCity innerCity = await db.InnerCities.FindAsync(id); if (innerCity == null) { return(NotFound()); } return(Ok(innerCity)); }
public async Task <IHttpActionResult> PostInnerCity(InnerCity innerCity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.InnerCities.Add(innerCity); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = innerCity.Id }, innerCity)); }
public async Task <IHttpActionResult> DeleteInnerCity(int id) { InnerCity innerCity = await db.InnerCities.FindAsync(id); if (innerCity == null) { return(NotFound()); } db.InnerCities.Remove(innerCity); await db.SaveChangesAsync(); return(Ok(innerCity)); }