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); }