public async Task <IHttpActionResult> GetBAIBAO(int id) { BAIBAO bAIBAO = await db.BAIBAO.FindAsync(id); if (bAIBAO == null) { return(NotFound()); } return(Ok(bAIBAO)); }
public async Task <IHttpActionResult> PostBAIBAO(BAIBAO bAIBAO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.BAIBAO.Add(bAIBAO); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = bAIBAO.ID }, bAIBAO)); }
public async Task <IHttpActionResult> DeleteBAIBAO(int id) { BAIBAO bAIBAO = await db.BAIBAO.FindAsync(id); if (bAIBAO == null) { return(NotFound()); } db.BAIBAO.Remove(bAIBAO); await db.SaveChangesAsync(); return(Ok(bAIBAO)); }
public async Task <IHttpActionResult> PutBAIBAO(BAIBAO bAIBAO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Entry(bAIBAO).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { } return(StatusCode(HttpStatusCode.NoContent)); }