public HttpResponseMessage PutCropMaterial_AudioAllocation(int id, CropMaterial_AudioAllocation cropMaterial_AudioAllocation) { if (!ModelState.IsValid) { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty })); } if (id != cropMaterial_AudioAllocation.Id) { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty })); } db.Entry(cropMaterial_AudioAllocation).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CropMaterial_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 { cropMaterial_AudioAllocation }, success = true, error = string.Empty })); }
public IHttpActionResult DeleteCropMaterial_AudioAllocation(int id) { CropMaterial_AudioAllocation cropMaterial_AudioAllocation = db.CropMaterial_AudioAllocation.Find(id); if (cropMaterial_AudioAllocation == null) { return(NotFound()); } db.CropMaterial_AudioAllocation.Remove(cropMaterial_AudioAllocation); db.SaveChanges(); return(Ok(cropMaterial_AudioAllocation)); }
public HttpResponseMessage PostCropMaterial_AudioAllocation(CropMaterial_AudioAllocation cropMaterial_AudioAllocation) { if (!ModelState.IsValid) { return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty })); } int recordCount = db.CropMaterial_AudioAllocation.Where(a => a.MaterialId == cropMaterial_AudioAllocation.MaterialId && a.LangId == cropMaterial_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 Crop Step Material." })); } db.CropMaterial_AudioAllocation.Add(cropMaterial_AudioAllocation); db.SaveChanges(); return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { id = cropMaterial_AudioAllocation.Id }, success = true, error = string.Empty })); }