示例#1
0
        public IHttpActionResult PostOrdenes(Models.Ordenes ordenes)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Ordenes.Add(ordenes);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (OrdenesExists(ordenes.ordenId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = ordenes.ordenId }, ordenes));
        }
示例#2
0
        public IHttpActionResult PutOrdenes(int id, Models.Ordenes ordenes)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != ordenes.ordenId)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrdenesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#3
0
        public IHttpActionResult GetOrdenes(int id)
        {
            Models.Ordenes ordenes = db.Ordenes.Find(id);
            if (ordenes == null)
            {
                return(NotFound());
            }

            return(Ok(ordenes));
        }
示例#4
0
        public IHttpActionResult DeleteOrdenes(int id)
        {
            Models.Ordenes ordenes = db.Ordenes.Find(id);
            if (ordenes == null)
            {
                return(NotFound());
            }

            db.Ordenes.Remove(ordenes);
            db.SaveChanges();

            return(Ok(ordenes));
        }