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

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

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Crop_VideoAllocationExists(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_VideoAllocation }, success = true, error = string.Empty }));
        }
Ejemplo n.º 2
0
        public IHttpActionResult DeleteCrop_VideoAllocation(int id)
        {
            Crop_VideoAllocation crop_VideoAllocation = db.Crop_VideoAllocation.Find(id);

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

            db.Crop_VideoAllocation.Remove(crop_VideoAllocation);
            db.SaveChanges();

            return(Ok(crop_VideoAllocation));
        }
Ejemplo n.º 3
0
        public HttpResponseMessage PostCrop_VideoAllocation(Crop_VideoAllocation crop_VideoAllocation)
        {
            if (!ModelState.IsValid)
            {
                return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty }));
            }

            int recordCount = db.Crop_VideoAllocation.Where(a => a.CropId == crop_VideoAllocation.CropId && a.LangId == crop_VideoAllocation.LangId && a.Active == true).Count();

            if (recordCount > 0)
            {
                return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { string.Empty }, success = false, error = "Video already allocated with this Crop." }));
            }

            db.Crop_VideoAllocation.Add(crop_VideoAllocation);
            db.SaveChanges();

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