public async Task <IActionResult> PutOrderDetail(int id, OrderDetail orderDetail)
        {
            if (id != orderDetail.OrderId)
            {
                return(BadRequest());
            }

            _context.Entry(orderDetail).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrderDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
        public bool CancelOrder(string mobile, int orderId)
        {
            var orders = this.GetOrders(mobile);
            var order  = orders.SingleOrDefault(o => o.Id.Equals(orderId));

            if (order != null)
            {
                var newOrder = order;
                newOrder.Type = Type.Cancel;
                _context.Entry(order).CurrentValues.SetValues(newOrder);
                _context.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }