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

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

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LiveStock_Steps_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_Steps_AudioAllocation }, success = true, error = string.Empty }));
        }
Ejemplo n.º 2
0
        public IHttpActionResult DeleteLiveStock_Steps_AudioAllocation(int id)
        {
            LiveStock_Steps_AudioAllocation liveStock_Steps_AudioAllocation = db.LiveStock_Steps_AudioAllocation.Find(id);

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

            db.LiveStock_Steps_AudioAllocation.Remove(liveStock_Steps_AudioAllocation);
            db.SaveChanges();

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

            int recordCount = db.LiveStock_Steps_AudioAllocation.Where(a => a.LiveStockStepId == liveStock_Steps_AudioAllocation.LiveStockStepId && a.LangId == liveStock_Steps_AudioAllocation.LangId && a.FieldType == liveStock_Steps_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 Step." }));
            }

            db.LiveStock_Steps_AudioAllocation.Add(liveStock_Steps_AudioAllocation);
            db.SaveChanges();

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