public async Task <IHttpActionResult> PutEki(int id, Eki eki) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != eki.EkiId) { return(BadRequest()); } db.Entry(eki).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EkiExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetEki(int id) { Eki eki = await db.Ekis.FindAsync(id); if (eki == null) { return(NotFound()); } return(Ok(eki)); }
public async Task <IHttpActionResult> PostEki(Eki eki) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Ekis.Add(eki); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = eki.EkiId }, eki)); }
public async Task <IHttpActionResult> DeleteEki(int id) { Eki eki = await db.Ekis.FindAsync(id); if (eki == null) { return(NotFound()); } db.Ekis.Remove(eki); await db.SaveChangesAsync(); return(Ok(eki)); }