public IHttpActionResult PutLists(decimal id, lineapedido lineapedido) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != lineapedido.id) { return(BadRequest()); } db.Entry(lineapedido).State = EntityState.Modified; try { string sql = String.Format("update lineapedido set idPedido = '{0}', idCoche = '{1}', precioCoche = '{2}' where id like {3}", lineapedido.idPedido, lineapedido.idCoche, lineapedido.precioCoche, id); db.Database.ExecuteSqlCommand(sql); //db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ListsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.OK)); }
public IHttpActionResult DeleteLists(decimal id) { lineapedido lineapedidos = db.lineapedidoes.Find(id); if (lineapedidos == null) { return(NotFound()); } db.lineapedidoes.Remove(lineapedidos); db.SaveChanges(); return(Ok(lineapedidos)); }
public IHttpActionResult PostLists(lineapedido lineapedido) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } string sql = String.Format("insert into lineapedido (idPedido, idCoche, precioCoche) values ('{0}', '{1}', '{2}')", lineapedido.idPedido, lineapedido.idCoche, lineapedido.precioCoche); db.Database.ExecuteSqlCommand(sql); //db.lineapedido.Add(lineapedidos); //db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = lineapedido.id }, lineapedido)); }