public async Task<HttpResponseMessage> PutRevenueStatistic(RevenueStatistic revenueStatistic) { JObject result = new JObject(); if (!ModelState.IsValid) { return Request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } db.Entry(revenueStatistic).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RevenueStatisticExists(revenueStatistic.Id)) { result = Methods.CustomResponseMessage(0, "Request isn't exists!"); return Request.CreateResponse(HttpStatusCode.NotFound, result); } else { throw; } } result = Methods.CustomResponseMessage(1, "Put Request is successful!"); return Request.CreateResponse(HttpStatusCode.OK, result); }
public async Task<HttpResponseMessage> PostRevenueStatistic(RevenueStatistic revenueStatistic) { JObject result = new JObject(); if (!ModelState.IsValid) { return Request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } db.RevenueStatistics.Add(revenueStatistic); await db.SaveChangesAsync(); result = Methods.CustomResponseMessage(1, "Post Request is successful!"); return Request.CreateResponse(HttpStatusCode.OK, result); }