public ActionResult GetAllEmployeesReport() { _dataUnitOfWork = new DataUnitOfWork(); _employeeService = new EmployeeService(new EmployeeRepository(_dataUnitOfWork), new EmploymentTypeRepository(_dataUnitOfWork), new PositionRepository(_dataUnitOfWork), new ProgramRepository(_dataUnitOfWork), new RoleRepository(_dataUnitOfWork), new EmployeeProgramRepository(_dataUnitOfWork)); // Build report name var reportName = string.Format("All Employees as of {0}", DateTime.Now.ToShortDateString()); // Get report data var reportData = _employeeService.GetAllEmployeesReport(); return File(Encoding.UTF8.GetBytes(reportData.ToString()), "text/csv", reportName + ".csv"); }