public async Task <IHttpActionResult> PostStoreQuestion(StoreQuestion storeQuestion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.StoreQuestions.Add(storeQuestion); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (StoreQuestionExists(storeQuestion.StoreNo)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = storeQuestion.StoreNo }, storeQuestion)); }
public async Task <IHttpActionResult> PutStoreQuestion(int id, StoreQuestion storeQuestion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != storeQuestion.StoreNo) { return(BadRequest()); } db.Entry(storeQuestion).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StoreQuestionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetStoreQuestion(int id) { StoreQuestion storeQuestion = await db.StoreQuestions.FindAsync(id); if (storeQuestion == null) { return(NotFound()); } return(Ok(storeQuestion)); }
public async Task <IHttpActionResult> DeleteStoreQuestion(int id) { StoreQuestion storeQuestion = await db.StoreQuestions.FindAsync(id); if (storeQuestion == null) { return(NotFound()); } db.StoreQuestions.Remove(storeQuestion); await db.SaveChangesAsync(); return(Ok(storeQuestion)); }