Exemplo n.º 1
0
        private List <DealershipPerformanceStatus> BuildStatuses(IEnumerable <int> dealershipIds, DateTime start, DateTime end)
        {
            var statuses = new List <DealershipPerformanceStatus>();

            foreach (var id in dealershipIds)
            {
                // select N+1 - potentially bad for performance and efficiency
                // re-using existing domain code - quick to implement
                var dealership = repository.Get(id);
                var targets    = provider.Get(dealership, start, end);
                var actuals    = calculator.CalculateFor(dealership, start, end);

                // map from domain to view model so UI is not coupled to domain objects
                // could move this logic into a separate mapper
                statuses.Add(new DealershipPerformanceStatus
                {
                    DealershipName = dealership.Name,
                    TotalRevenue   = actuals.TotalRevenue,
                    TargetRevenue  = targets.TargetRevenue,
                    NetProfit      = actuals.NetProfit,
                    TargetProfit   = targets.TargetProfit
                });
            }
            return(statuses);
        }
Exemplo n.º 2
0
        public ActionResult Index(IEnumerable <int> dealershipIds, DateTime start, DateTime end)
        {
            var dealerships = repository.Get(dealershipIds);
            var builder     = new DealershipPerformanceReportBuilderUsingMediator();
            var viewModel   = builder.BuildReport(dealerships, start, end);

            return(View(viewModel));
        }