public HttpResponseMessage PutLiveStock_Steps_AudioAllocation(int id, LiveStock_Steps_AudioAllocation liveStock_Steps_AudioAllocation) { if (!ModelState.IsValid) { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty })); } if (id != liveStock_Steps_AudioAllocation.Id) { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty })); } db.Entry(liveStock_Steps_AudioAllocation).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LiveStock_Steps_AudioAllocationExists(id)) { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.NotFound, new { data = new { string.Empty }, success = false, error = string.Empty })); } else { throw; } } return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { liveStock_Steps_AudioAllocation }, success = true, error = string.Empty })); }
public IHttpActionResult DeleteLiveStock_Steps_AudioAllocation(int id) { LiveStock_Steps_AudioAllocation liveStock_Steps_AudioAllocation = db.LiveStock_Steps_AudioAllocation.Find(id); if (liveStock_Steps_AudioAllocation == null) { return(NotFound()); } db.LiveStock_Steps_AudioAllocation.Remove(liveStock_Steps_AudioAllocation); db.SaveChanges(); return(Ok(liveStock_Steps_AudioAllocation)); }
public HttpResponseMessage PostLiveStock_Steps_AudioAllocation(LiveStock_Steps_AudioAllocation liveStock_Steps_AudioAllocation) { if (!ModelState.IsValid) { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty })); } int recordCount = db.LiveStock_Steps_AudioAllocation.Where(a => a.LiveStockStepId == liveStock_Steps_AudioAllocation.LiveStockStepId && a.LangId == liveStock_Steps_AudioAllocation.LangId && a.FieldType == liveStock_Steps_AudioAllocation.FieldType && a.Active == true).Count(); if (recordCount > 0) { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { string.Empty }, success = false, error = "Audio already allocated with this Live Stock Step." })); } db.LiveStock_Steps_AudioAllocation.Add(liveStock_Steps_AudioAllocation); db.SaveChanges(); return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { id = liveStock_Steps_AudioAllocation.Id }, success = true, error = string.Empty })); }