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)); }
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)); }
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)); }
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)); }