public HttpResponseMessage PutLiveStockBreed_AudioAllocation(int id, LiveStockBreed_AudioAllocation liveStockBreed_AudioAllocation) { if (!ModelState.IsValid) { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty })); } if (id != liveStockBreed_AudioAllocation.Id) { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty })); } db.Entry(liveStockBreed_AudioAllocation).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LiveStockBreed_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 { liveStockBreed_AudioAllocation }, success = true, error = string.Empty })); }
public IHttpActionResult DeleteLiveStockBreed_AudioAllocation(int id) { LiveStockBreed_AudioAllocation liveStockBreed_AudioAllocation = db.LiveStockBreed_AudioAllocation.Find(id); if (liveStockBreed_AudioAllocation == null) { return(NotFound()); } db.LiveStockBreed_AudioAllocation.Remove(liveStockBreed_AudioAllocation); db.SaveChanges(); return(Ok(liveStockBreed_AudioAllocation)); }
public HttpResponseMessage PostLiveStockBreed_AudioAllocation(LiveStockBreed_AudioAllocation liveStockBreed_AudioAllocation) { if (!ModelState.IsValid) { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty })); } int recordCount = db.LiveStockBreed_AudioAllocation.Where(a => a.LiveStockBreedId == liveStockBreed_AudioAllocation.LiveStockBreedId && a.LangId == liveStockBreed_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 Breed." })); } db.LiveStockBreed_AudioAllocation.Add(liveStockBreed_AudioAllocation); db.SaveChanges(); return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { id = liveStockBreed_AudioAllocation.Id }, success = true, error = string.Empty })); }