예제 #1
0
        public IHttpActionResult DeleteLiveStock_StepsMaterial_AudioAllocation(int id)
        {
            LiveStock_StepsMaterial_AudioAllocation liveStock_StepsMaterial_AudioAllocation = db.LiveStock_StepsMaterial_AudioAllocation.Find(id);

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

            db.LiveStock_StepsMaterial_AudioAllocation.Remove(liveStock_StepsMaterial_AudioAllocation);
            db.SaveChanges();

            return(Ok(liveStock_StepsMaterial_AudioAllocation));
        }
예제 #2
0
        public HttpResponseMessage PostLiveStock_StepsMaterial_AudioAllocation(LiveStock_StepsMaterial_AudioAllocation liveStock_StepsMaterial_AudioAllocation)
        {
            if (!ModelState.IsValid)
            {
                return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty }));
            }

            int recordCount = db.LiveStock_StepsMaterial_AudioAllocation.Where(a => a.LiveStockStepMaterialId == liveStock_StepsMaterial_AudioAllocation.LiveStockStepMaterialId && a.LangId == liveStock_StepsMaterial_AudioAllocation.LangId && a.FieldType == liveStock_StepsMaterial_AudioAllocation.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 Live Stock Breed Category." }));
            }

            db.LiveStock_StepsMaterial_AudioAllocation.Add(liveStock_StepsMaterial_AudioAllocation);
            db.SaveChanges();

            return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.OK, new { data = new { id = liveStock_StepsMaterial_AudioAllocation.Id }, success = true, error = string.Empty }));
        }
예제 #3
0
        public HttpResponseMessage PutLiveStock_StepsMaterial_AudioAllocation(int id, LiveStock_StepsMaterial_AudioAllocation liveStock_StepsMaterial_AudioAllocation)
        {
            if (!ModelState.IsValid)
            {
                return((HttpResponseMessage)Request.CreateResponse(HttpStatusCode.BadRequest, new { data = new { string.Empty }, success = false, error = string.Empty }));
            }

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

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LiveStock_StepsMaterial_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 { liveStock_StepsMaterial_AudioAllocation }, success = true, error = string.Empty }));
        }