public static void AppsFindOrCreateAsDependable(ISession session, ProductCategoryRevenue dependant) { foreach (ProductCategory parentCategory in dependant.ProductCategory.Parents) { var productCategoryRevenues = parentCategory.ProductCategoryRevenuesWhereProductCategory; productCategoryRevenues.Filter.AddEquals(ProductCategoryRevenues.Meta.InternalOrganisation, dependant.InternalOrganisation); productCategoryRevenues.Filter.AddEquals(ProductCategoryRevenues.Meta.Year, dependant.Year); productCategoryRevenues.Filter.AddEquals(ProductCategoryRevenues.Meta.Month, dependant.Month); var productCategoryRevenue = productCategoryRevenues.First ?? new ProductCategoryRevenueBuilder(session) .WithInternalOrganisation(dependant.InternalOrganisation) .WithProductCategory(parentCategory) .WithYear(dependant.Year) .WithMonth(dependant.Month) .WithCurrency(dependant.Currency) .WithRevenue(0M) .Build(); AppsFindOrCreateAsDependable(session, productCategoryRevenue); } }
private static ProductCategoryRevenueHistory CreateProductCategoryRevenueHistory(ISession session, ProductCategoryRevenue productCategoryRevenue) { return new ProductCategoryRevenueHistoryBuilder(session) .WithCurrency(productCategoryRevenue.Currency) .WithInternalOrganisation(productCategoryRevenue.InternalOrganisation) .WithProductCategory(productCategoryRevenue.ProductCategory) .WithRevenue(0) .Build(); }