public void HaveUserResolveConcurrency(BarrilModel entity, BarrilModel databaseValues, BarrilModel resolvedValues) { // Show the current, database, and resolved values to the user and have // them update the resolved values to get the correct resolution. }
public IHttpActionResult UpdateAllBarrilModel([FromBody] BarrilModel barrilModel) { db.BarrilModels.ToList().ForEach(barril => { if (barrilModel.idEstado != 0) { barril.idEstado = barrilModel.idEstado; } if (barril.idEntrega != null) { barril.idEntrega = barrilModel.idEntrega; } if (barrilModel.IdEstilo != null) { barril.IdEstilo = barrilModel.IdEstilo; } db.Entry(barril).State = EntityState.Modified; }); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SaveChanges(); return(StatusCode(HttpStatusCode.OK)); }
public IHttpActionResult PutBarrilModel([FromBody] BarrilModel barrilModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //if (id != barrilModel.id) //{ // return BadRequest(); //} db.Entry(barrilModel).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return(BadRequest(ex.Message)); } return(StatusCode(HttpStatusCode.OK)); }
public IHttpActionResult GetBarrilModel(int id) { BarrilModel barrilModel = db.BarrilModels.Include(x => x.Estilo).Where(y => y.id == id).Include(x => x.Estilo.rangoPrecio).FirstOrDefault(); if (barrilModel == null) { return(NotFound()); } return(Ok(barrilModel)); }
public IHttpActionResult PatchBarrilModel([FromBody] BarrilModel barril) { try { BarrilModel serverDocument = db.BarrilModels.Where(x => x.NroBarril == barril.NroBarril).Include(x => x.Coccion).SingleOrDefault(); // barril.id = serverDocument.id; if (barril.idEstado != 0) { serverDocument.idEstado = barril.idEstado; } if (barril.idEntrega != null) { serverDocument.idEntrega = barril.idEntrega; } if (barril.IdEstilo != null) { serverDocument.IdEstilo = barril.IdEstilo; } if (barril.Coccion != null) { //barril.Coccion = serverDocument.Coccion; //serverDocument.Coccion = barril.Coccion; // db.Entry(barril.Coccion).State = EntityState.Unchanged; serverDocument.Coccion_id = barril.Coccion_id; //db.Entry(serverDocument).Reference(x => x.Coccion).CurrentValue = barril.Coccion; // serverDocument.Coccion = barril.Coccion; //db.Entry(serverDocument.Coccion).State = EntityState.Unchanged; //db.Entry(serverDocument.Coccion.Receta).State = EntityState.Unchanged; //db.Entry(serverDocument.Coccion.Fermentador).State = EntityState.Unchanged; } db.Entry(barril).State = EntityState.Detached; //db.Entry(serverDocument).CurrentValues.SetValues(barril); //db.Entry(serverDocument.Coccion).State = EntityState.Unchanged; //db.Entry(serverDocument).State = EntityState.Modified; //db.Entry(serverDocument.Coccion).State = EntityState.Unchanged; //db.Entry(serverDocument).State = EntityState.Modified; //db.Entry(barril).State = EntityState.Added; //db.Entry(barril.Coccion).State = EntityState.Detached; db.SaveChanges(); } catch (OptimisticConcurrencyException ex) { var result = ex.Data; } return(StatusCode(HttpStatusCode.OK)); }
public IHttpActionResult DeleteBarrilModel(int id) { BarrilModel barrilModel = db.BarrilModels.Find(id); if (barrilModel == null) { return(NotFound()); } db.BarrilModels.Remove(barrilModel); db.SaveChanges(); return(Ok(barrilModel)); }
public IHttpActionResult PostBarrilModel([FromBody] BarrilModel barrilModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (barrilModel.Coccion != null) { barrilModel.Coccion.Receta = null; //db.EstilosModels.Attach(barrilModel.Coccion.Receta.Estilo); //ctx.Entry(barrilModel.Coccion.Receta.Estilo).State = EntityState.Detached; //db.RecetaModels.Attach(barrilModel.Coccion.Receta); db.CoccionModels.Attach(barrilModel.Coccion); db.EstilosModels.Attach(barrilModel.Estilo); //ctx.Entry(barrilModel.Coccion.Receta).State = EntityState.Detached; //db.Entry(barrilModel.Coccion.Receta).State = EntityState.Unchanged; //ctx.Entry(barrilModel.Coccion).State = EntityState.Unchanged; } if (barrilModel.Entrega != null) { db.Entry(barrilModel.Entrega).State = EntityState.Unchanged; } db.BarrilModels.Add(barrilModel); db.SaveChanges(); return(Ok(new { id = barrilModel.id })); // return CreatedAtRoute("DefaultApi", new { id = barrilModel.id }, barrilModel); }