public async Task<IHttpActionResult> PutStatisticRating(int id, StatisticRating statisticRating) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != statisticRating.ID) { return BadRequest(); } db.Entry(statisticRating).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StatisticRatingExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public HttpResponseMessage PostStatisticRating(StatisticRating statisticRating) { JObject response = new JObject(); try { var userId = new SqlParameter("@UserId", statisticRating.UserID); var storeId = new SqlParameter("@StoreId", statisticRating.StoreID); var rate = new SqlParameter("@Rate", statisticRating.RateOfUser); var result = Methods.GetInstance().ExecQueryWithResult("viethung_paybayservice.sp_UserRate",CommandType.StoredProcedure,ref Methods.err, userId, storeId, rate); response = result[0].ToObject<JObject>(); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); } return Request.CreateResponse(HttpStatusCode.OK, response); }