public Order(string id, string userId, IEnumerable <string> productsIds, ProductsCatalog productsCatalog) { Id = id ?? throw new ArgumentNullException(nameof(id)); UserId = userId ?? throw new ArgumentNullException(nameof(userId)); ProductsIds = productsIds ?? throw new ArgumentNullException(nameof(productsIds)); _productsCatalog = productsCatalog ?? throw new ArgumentNullException(nameof(productsCatalog)); }
public static IObservable <Product> FindMostExpansivePurchase( IObservable <Order> ordersHistory, ProductsCatalog productsCatalog) { IObservable <Product> allOrdersProducts = ordersHistory.SelectMany(order => order.ProductsIds.Select(id => productsCatalog.FindById(id))); IObservable <long> maxProductPrice = allOrdersProducts.Max(price => price.Price); return(maxProductPrice.SelectMany(price => allOrdersProducts.Where(product => product.Price == price))); }