示例#1
0
        public void UpdateOrder(Order order)
        {
            var newDetail = order.OrderDetail;

            var oldDetails = _orderDetailRepository.GetMany(x => x.OrderId == order.Id);

            foreach (var old in oldDetails)
            {
                _orderDetailRepository.Delete(old);
                _unitOfWork.Commit();
            }
            foreach (var detail in newDetail)
            {
                CreateOrderDetail(detail);
            }
            _orderRepository.Update(order);
            order.Total = newDetail.Sum(x => x.Price * x.Quantity);
            SaveOrder();
        }