public async Task <IActionResult> PutProduct([FromRoute] string id, [FromBody] Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.ProductId) { return(BadRequest()); } _context.Entry(product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); return(Ok(product)); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } }
public async Task <IActionResult> PutOrderItem([FromRoute] int id, [FromBody] OrderItem orderItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != orderItem.OrderItemId) { return(BadRequest()); } _context.Entry(orderItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); return(Ok(orderItem)); } catch (DbUpdateConcurrencyException) { if (!OrderItemExists(id)) { return(NotFound()); } else { throw; } } }
public async Task <IActionResult> PutSalesperson([FromRoute] int id, [FromBody] Salesperson salesperson) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != salesperson.SalespersonId) { return(BadRequest()); } _context.Entry(salesperson).State = EntityState.Modified; try { await _context.SaveChangesAsync(); return(Ok(salesperson)); } catch (DbUpdateConcurrencyException) { if (!SalespersonExists(id)) { return(NotFound()); } else { throw; } } }