public async Task <IActionResult> UpdateProduct(int id, Product product) { if (id != product.Id) { return(BadRequest()); } _context.Products.Update(product); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
//POST : /api/orders/UpdateStateDone public async Task <IActionResult> UpdateStatusDeActive(int id) { var order = await _context.Orders.FindAsync(id); if (order.State == "pending") { order.State = "Done"; } else { return(BadRequest(new { message = "Đã thanh toán rồi." })); } await _context.SaveChangesAsync(); return(NoContent()); }