예제 #1
0
        public IHttpActionResult PutEstilosModel(EstilosModel estilosModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //if (id != estilosModel.IdEstilo)
            //{
            //    return BadRequest();
            //}

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(BadRequest(ex.Message));
                //if (!EstilosModelExists(id))
                //{
                //    return NotFound();
                //}
                //else
                //{
                //    throw;
                //}
            }

            return(StatusCode(HttpStatusCode.OK));
        }
예제 #2
0
        public IHttpActionResult GetEstilosModel(int id)
        {
            EstilosModel estilosModel = db.EstilosModels.Include(x => x.rangoPrecio).Where(x => x.IdEstilo == id).FirstOrDefault();

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

            return(Ok(estilosModel));
        }
예제 #3
0
        public IHttpActionResult PostEstilosModel(EstilosModel estilosModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            db.Entry(estilosModel.rangoPrecio).State = EntityState.Unchanged;
            db.EstilosModels.Add(estilosModel);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = estilosModel.IdEstilo }, estilosModel));
        }
예제 #4
0
        public IHttpActionResult DeleteEstilosModel(int id)
        {
            EstilosModel estilosModel = db.EstilosModels.Find(id);

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

            db.EstilosModels.Remove(estilosModel);
            db.SaveChanges();

            return(Ok(estilosModel));
        }