public async Task <IActionResult> AlterarProduto(int id, Produtos produto) { var entityId = produto.ID; if (id != entityId) { return(BadRequest()); } _context.Entry(produto).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProdutosExists(id)) { return(NotFound()); } else { throw; } } return(Ok(await _context.Produtos.FindAsync(entityId))); }
public async Task <IActionResult> PutStockDelivery(int id, StockDelivery stockDelivery) { if (id != stockDelivery.DeliveryID) { return(BadRequest()); } _context.Entry(stockDelivery).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StockDeliveryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutStock(int id, StockViewModel stockvm) { Product product = null; try { product = _context.Products.Single(i => i.ProductID == stockvm.ProductID); } catch (ArgumentNullException) { return(BadRequest()); } catch (InvalidOperationException) { return(BadRequest()); } if (product == null) { return(NotFound()); } Stock stock = new Stock { StockID = id, ProductID = stockvm.ProductID, Product = product, Quantity = stockvm.Quantity, Threshold = stockvm.Threshold, ExpiryDate = stockvm.ExpiryDate, Supplier = stockvm.Supplier, Description = stockvm.Description }; _context.Entry(stock).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StockExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEquipo(char id, Equipo equipo) { if (id != equipo.NumSerie) { return(BadRequest()); } _context.Entry(equipo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EquipoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTasks([FromRoute] int id, [FromBody] Tasks tasks) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tasks.ID) { return(BadRequest()); } _context.Entry(tasks).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TasksExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCientifico(string id, Cientifico cientifico) { if (id != cientifico.DNI) { return(BadRequest()); } _context.Entry(cientifico).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CientificoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task<IHttpActionResult> PutVol(int id, Vol vol) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != vol.Id) { return BadRequest("valeur fausse"); } db.Entry<Vol>(vol).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VolExists(id)) { return NotFound(); } else { throw; } } return Ok(vol); }
public async Task <IActionResult> PutSuministra(int id, Suministra suministra) { if (id != suministra.CodigoPieza) { return(BadRequest()); } _context.Entry(suministra).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SuministraExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
//Updates a specific supplier and returns an HTTP status code in Postman etc. //If an Id for a supplier that doesn't exist is used, you'll see the Bad Request error - 400 //If an Id for a supplier that was deleted just a moment ago is used, you'll see the Not FOund error - 404 public async Task <IActionResult> PutSupplier([FromRoute] int id, [FromBody] Supplier supplier) { if (id != supplier.Id) { return(BadRequest()); } _context.Entry(supplier).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (_context.Suppliers.Find(id) == null) { return(NotFound()); } throw; } return(NoContent()); }
public async Task <IActionResult> PutDepartamento(int codigo, Departamento departamento) { if (codigo != departamento.Codigo) { return(BadRequest()); } _context.Entry(departamento).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartamentoExists(codigo)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutMaquina(int id, Maquina maquina) { if (id != maquina.Codigo) { return(BadRequest()); } _context.Entry(maquina).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MaquinaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPlanoDeEnsino([FromRoute] int id, [FromBody] PlanoDeEnsino planoDeEnsino) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != planoDeEnsino.PlanoEnsinoId) { return(BadRequest()); } _context.Entry(planoDeEnsino).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlanoDeEnsinoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutArticulo(int id, Articulo articulo) { if (id != articulo.Codigo) { return(BadRequest()); } _context.Entry(articulo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ArticuloExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEOLAudit(int id, EOLAudit eOLAudit) { if (id != eOLAudit.EOLID) { return(BadRequest()); } _context.Entry(eOLAudit).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EOLAuditExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutSalesRep(int id, SalesRep salesRep) { if (id != salesRep.RepID) { return(BadRequest()); } _context.Entry(salesRep).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SalesRepExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAdministrador([FromRoute] int id, [FromBody] Administrador administrador) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != administrador.UsuarioId) { return(BadRequest()); } _context.Entry(administrador).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdministradorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProveedor(string id, Proveedor proveedor) { if (id != proveedor.Id) { return(BadRequest()); } _context.Entry(proveedor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProveedorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutVideo(int id, Video video) { if (id != video.Id) { return(BadRequest()); } _context.Entry(video).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VideoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPost(long id, Post post) { if (id != post.ID) { return(BadRequest()); } _context.Entry(post).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutItemField(int id, ItemField itemField) { if (id != itemField.ItemId) { return(BadRequest()); } _context.Entry(itemField).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemFieldExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutReserva(string id, Reserva reserva) { if (id != reserva.Dni) { return(BadRequest()); } _context.Entry(reserva).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReservaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCaja(int id, Caja caja) { if (id != caja.NumReferencia) { return(BadRequest()); } _context.Entry(caja).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CajaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutSala(int Codigo, Sala sala) { if (Codigo != sala.Codigo) { return(BadRequest()); } _context.Entry(sala).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SalaExists(Codigo)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAnswer(Guid id, Answer answer) { if (id != answer.AnswerId) { return(BadRequest()); } _context.Entry(answer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnswerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Put(Guid id, Enterprise emp) { if (id != emp.Id) { return(BadRequest()); } _context.Entry(emp).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnterprisExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCursoDisciplina([FromRoute] int id, [FromBody] CursoDisciplina cursoDisciplina) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cursoDisciplina.CursoDisciplinaId) { return(BadRequest()); } _context.Entry(cursoDisciplina).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CursoDisciplinaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEmpleado(string id, Empleado empleado) { if (id != empleado.Dni) { return(BadRequest()); } _context.Entry(empleado).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmpleadoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IHttpActionResult> PutAuth(int id, Auth auth) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != auth.id) { return(BadRequest()); } db.Entry(auth).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AuthExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutFabricante(int id, Fabricante fabricante) { if (id != fabricante.Codigo) { return(BadRequest()); } _context.Entry(fabricante).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FabricanteExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProductTypes(int id, ProductType productType) { if (id != productType.ProductTypeID) { return(BadRequest()); } _context.Entry(productType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }