public HttpResponseMessage PutLiveStock_AudioAllocation(int id, LiveStock_AudioAllocation liveStock_AudioAllocation) { if (!ModelState.IsValid) { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty })); } if (id != liveStock_AudioAllocation.Id) { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty })); } db.Entry(liveStock_AudioAllocation).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LiveStock_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_AudioAllocation }, success = true, error = string.Empty })); }
public IHttpActionResult DeleteLiveStock_AudioAllocation(int id) { LiveStock_AudioAllocation liveStock_AudioAllocation = db.LiveStock_AudioAllocation.Find(id); if (liveStock_AudioAllocation == null) { return(NotFound()); } db.LiveStock_AudioAllocation.Remove(liveStock_AudioAllocation); db.SaveChanges(); return(Ok(liveStock_AudioAllocation)); }
public HttpResponseMessage PostLiveStock_AudioAllocation(LiveStock_AudioAllocation liveStock_AudioAllocation) { if (!ModelState.IsValid) { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty })); } int recordCount = db.LiveStock_AudioAllocation.Where(a => a.LiveStockId == liveStock_AudioAllocation.LiveStockId && a.LangId == liveStock_AudioAllocation.LangId && 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." })); } db.LiveStock_AudioAllocation.Add(liveStock_AudioAllocation); db.SaveChanges(); return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { id = liveStock_AudioAllocation.Id }, success = true, error = string.Empty })); }