コード例 #1
0
        public void GetRevenuePairByTest(IEnumerable <HealthPlanRevenueItem> accountRevenueItems, HealthPlanRevenue revenue, List <OrderedPair <long, decimal> > list)
        {
            var testIdRevenueItems = accountRevenueItems.Where(x => x.TestId.HasValue);
            var testIds            = testIdRevenueItems.Select(x => x.TestId.Value).Distinct();

            var testAvailedTestPair = _eventCustomerRepository.GetTestAvailedForHealthPlanRevenueByTest(revenue.AccountId, revenue.DateFrom, revenue.DateTo ?? DateTime.Today.AddDays(1), testIds);
            var customerCountByTest = _eventCustomerRepository.GetCustomerCountForHealthPlanRevenueByTest(revenue.AccountId, revenue.DateFrom, revenue.DateTo ?? DateTime.Today.AddDays(1), testIds);

            decimal revenueGeneatedbyTest = 0;

            foreach (var testId in testIds)
            {
                var customersAvailedTestPair = testAvailedTestPair.SingleOrDefault(x => x.FirstValue == testId);

                if (customersAvailedTestPair != null)
                {
                    var customersAvailedTest = customersAvailedTestPair.SecondValue;

                    var testPrice = testIdRevenueItems.First(x => x.TestId.Value == testId).Price;

                    revenueGeneatedbyTest = revenueGeneatedbyTest + (testPrice * customersAvailedTest);
                }
            }

            list.Add(new OrderedPair <long, decimal>(customerCountByTest, revenueGeneatedbyTest));
        }