public HttpResponseMessage PutCropStepAudio_Allocation(int id, CropStepAudio_Allocation cropStepAudio_Allocation)
        {
            if (!ModelState.IsValid)
            {
                return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty }));
            }

            if (id != cropStepAudio_Allocation.Id)
            {
                return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty }));
            }

            db.Entry(cropStepAudio_Allocation).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CropStepAudio_AllocationExists(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 { cropStepAudio_Allocation }, success = true, error = string.Empty }));
        }
        public IHttpActionResult GetCropStepAudio_Allocation(int id)
        {
            CropStepAudio_Allocation cropStepAudio_Allocation = db.CropStepAudio_Allocation.Find(id);

            if (cropStepAudio_Allocation == null)
            {
                return(NotFound());
            }

            return(Ok(cropStepAudio_Allocation));
        }
        public IHttpActionResult DeleteCropStepAudio_Allocation(int id)
        {
            CropStepAudio_Allocation cropStepAudio_Allocation = db.CropStepAudio_Allocation.Find(id);

            if (cropStepAudio_Allocation == null)
            {
                return(NotFound());
            }

            db.CropStepAudio_Allocation.Remove(cropStepAudio_Allocation);
            db.SaveChanges();

            return(Ok(cropStepAudio_Allocation));
        }
        public HttpResponseMessage PostCropStepAudio_Allocation(CropStepAudio_Allocation cropStepAudio_Allocation)
        {
            if (!ModelState.IsValid)
            {
                return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty }));
            }

            int recordCount = db.CropStepAudio_Allocation.Where(a => a.StepId == cropStepAudio_Allocation.StepId && a.LangId == cropStepAudio_Allocation.LangId && a.FieldType == cropStepAudio_Allocation.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 Crop Step." }));
            }

            db.CropStepAudio_Allocation.Add(cropStepAudio_Allocation);
            db.SaveChanges();

            return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { id = cropStepAudio_Allocation.Id }, success = true, error = string.Empty }));
        }