/// <summary> /// Loads OrderItems into passed Order /// </summary> /// <param name="order"></param> public void LoadOrderItems(Order order) { if (order.Id == null) { throw new ArgumentNullException(nameof(order.Id), "Order Id is null"); } using (var connection = Connector.GetConnection()) { var orderItemDal = new OrderItemDal(connection); order.OrderItems = orderItemDal.Search(order.Id).ToList(); } }
/// <summary> /// Searches for all orders and returns matches /// </summary> /// <returns></returns> public IEnumerable <Order> GetOrders(bool?isCredit = null, uint?customerId = null, string note = null) { using (var connection = Connector.GetConnection()) { var orderDal = new OrderDal(connection); var orderItemDal = new OrderItemDal(connection); var orders = orderDal.Search(isCredit, customerId, note == null ? null : $"%{note}%"); foreach (var order in orders) { order.OrderItems = orderItemDal.Search(order.Id).ToList(); yield return(order); } } }