Exemplo n.º 1
0
        public HttpResponseMessage PutCrop_AudioAllocation(int id, Crop_AudioAllocation crop_AudioAllocation)
        {
            if (!ModelState.IsValid)
            {
                return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty }));
            }

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

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Crop_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 { crop_AudioAllocation }, success = true, error = string.Empty }));
        }
Exemplo n.º 2
0
        public IHttpActionResult GetCrop_AudioAllocation(int id)
        {
            Crop_AudioAllocation crop_AudioAllocation = db.Crop_AudioAllocation.Find(id);

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

            return(Ok(crop_AudioAllocation));
        }
Exemplo n.º 3
0
        public IHttpActionResult DeleteCrop_AudioAllocation(int id)
        {
            Crop_AudioAllocation crop_AudioAllocation = db.Crop_AudioAllocation.Find(id);

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

            db.Crop_AudioAllocation.Remove(crop_AudioAllocation);
            db.SaveChanges();

            return(Ok(crop_AudioAllocation));
        }
Exemplo n.º 4
0
        public HttpResponseMessage PostCrop_AudioAllocation(Crop_AudioAllocation crop_AudioAllocation)
        {
            if (!ModelState.IsValid)
            {
                return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty }));
            }

            int recordCount = db.Crop_AudioAllocation.Where(a => a.CropId == crop_AudioAllocation.CropId && a.LangId == crop_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." }));
            }

            db.Crop_AudioAllocation.Add(crop_AudioAllocation);
            db.SaveChanges();

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