常用方法
常用方法
常用方法
常用方法
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(); }