예제 #1
0
        public ActionResult GetXxDayReport(DateTime startDate, DateTime endDate, int count)
        {
            _dataUnitOfWork = new DataUnitOfWork();
            _employeeService = new EmployeeService(new EmployeeRepository(_dataUnitOfWork), new EmploymentTypeRepository(_dataUnitOfWork), new PositionRepository(_dataUnitOfWork), new ProgramRepository(_dataUnitOfWork), new RoleRepository(_dataUnitOfWork), new EmployeeProgramRepository(_dataUnitOfWork));

            // Adjust start/end dates to cover very start of day to
            // very end of day
            startDate = startDate.Date;
            endDate = new DateTime(endDate.Year, endDate.Month, endDate.Day, 23, 59, 59);

            // Build report name
            var reportName = string.Format("{0} Day Report for {1:yyyyMMdd}-{2:yyyMMdd}", count, startDate, endDate);

            if (startDate > endDate)
            {
                // Return empty file if not valid time span
                return File(Encoding.UTF8.GetBytes(string.Empty), "text/csv", reportName + ".csv");
            }

            // Get report data
            var reportData = _employeeService.GetXxDayReport(startDate, endDate, count);

            return File(Encoding.UTF8.GetBytes(reportData.ToString()), "text/csv", reportName + ".csv");
        }