Exemple #1
0
        public List <DomainReport> BuildReports(DateTime dateTime)
        {
            Interval dayInterval   = _intervalHelper.GetLastDay(dateTime);
            Interval weekInterval  = _intervalHelper.GetLastWeek(dateTime);
            Interval monthInterval = _intervalHelper.GetLastMonth(dateTime);

            ICompiler dayReportCompiler    = _compilerFactory.Create(dayInterval);
            ICompiler weekReportCompiler   = _compilerFactory.Create(weekInterval);
            ICompiler monthReportCompiler  = _compilerFactory.Create(monthInterval);
            ICompiler allDaysReortCompiler = _compilerFactory.Create(null);

            DomainReport dayReport     = dayReportCompiler.CompileReport();
            DomainReport weekReport    = weekReportCompiler.CompileReport(dayReport);
            DomainReport monthReport   = monthReportCompiler.CompileReport(dayReport);
            DomainReport allDaysReport = allDaysReortCompiler.CompileReport(dayReport);

            var reports = new List <DomainReport>
            {
                dayReport,
                weekReport,
                monthReport,
                allDaysReport
            };

            return(reports);
        }
Exemple #2
0
        public async Task <StandardReport> BuildReport(DateTime dateTime)
        {
            List <DomainReport> reports = await _standardReportService.GetReports(dateTime);

            DomainReport dayDomainReport     = reports.FirstOrDefault(p => p.Interval == "1");
            DomainReport weekDomainReport    = reports.FirstOrDefault(p => p.Interval == "7");
            DomainReport monthDomainReport   = reports.FirstOrDefault(p => p.Interval == "30");
            DomainReport allDaysDomainReport = reports.FirstOrDefault(p => p.Interval == "All");
            Interval     dayInterval         = _intervalHelper.GetLastDay(dateTime);
            Interval     weekInterval        = _intervalHelper.GetLastWeek(dateTime);
            Interval     monthInterval       = _intervalHelper.GetLastMonth(dateTime);
            Interval     allInterval         = _intervalHelper.GetAllDays(dateTime);

            Report dayReport     = _reportMapper.DomainReportToDto(dayDomainReport, dayInterval);
            Report weekReport    = _reportMapper.DomainReportToDto(weekDomainReport, weekInterval);
            Report monthReport   = _reportMapper.DomainReportToDto(monthDomainReport, monthInterval);
            Report allDaysReport = _reportMapper.DomainReportToDto(allDaysDomainReport, allInterval);

            return(new StandardReport
            {
                DateTime = dateTime,
                LastDay = dayReport,
                LastWeek = weekReport,
                LastMonth = monthReport,
                AllDays = allDaysReport
            });
        }