public OrdersIndex Add(IReadOnlyList <IUserOrder> newOrders, IReadOnlyList <IAssigningUserOrder> assigningOrders) { if (IsEmpty) { throw new InvalidOperationException("Index in empty"); } var allOrders = AllOrders.AddRange(newOrders); var newUnassignedOrdersDic = UnassignedOrders.RemoveRange(assigningOrders.SelectMany(o => o.Orders)).AddRange(newOrders); var allAssigningOrders = AssigningOrders.AddRange(assigningOrders); return(new OrdersIndex(allOrders, newUnassignedOrdersDic, allAssigningOrders)); }
internal IEnumerable <IUserOrder> SelectUnassignedOrders(IEnumerable <HashValue> orderHashes) { foreach (var orderHash in orderHashes) { IUserOrder userOrder; if (!UnassignedOrders.TryGetValue(orderHash, out userOrder)) { throw new TransactionDeclinedException(string.Format("Order {0} is not from unassigned set.", orderHash)); } yield return(userOrder); } }