public async Task <IActionResult> PutProduct([FromRoute] int id, [FromBody] ProductDTO product) { product.OrderDetail = null; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.Id) { return(BadRequest()); } _context.Entry(Mapper.Map <Product>(product)).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEmployee([FromRoute] int id, [FromBody] EmployeeDTO employee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employee.Id) { return(BadRequest()); } _context.Entry(Mapper.Map <Employee>(employee)).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutOrderStatus([FromRoute] int id, [FromBody] OrderStatusDTO orderStatus) { orderStatus.CustomerOrder = null; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != orderStatus.Id) { return(BadRequest()); } _context.Entry(Mapper.Map <OrderStatus>(orderStatus)).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderStatusExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCustomerOrder([FromRoute] int id, [FromBody] CustomerOrderDTO customerOrder) { customerOrder.OrderDetail = null; customerOrder.OrderStatus = null; customerOrder.Customer = null; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customerOrder.Id) { return(BadRequest()); } _context.Entry(Mapper.Map <CustomerOrder>(customerOrder)).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerOrderExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }