コード例 #1
0
 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());
 }
コード例 #2
0
        //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());
        }