Ejemplo n.º 1
0
        protected Task <FileContentResult> Export <T>(IEnumerable <T> select, string fileName, ExportType exportType = ExportType.Csv)
        {
            ExportDataService.BindDisplay <User>(user => user?.GetDisplayName());
            var generator = ExportDataService.GetGenerator(exportType, select);

            return(ReturnExportResult(fileName, generator));
        }
Ejemplo n.º 2
0
        private async Task <ActionResult> GetFinanceOperationsList(int projectid, string export, Func <FinanceOperation, bool> predicate)
        {
            var project = await ProjectRepository.GetProjectWithFinances(projectid);

            var viewModel = new FinOperationListViewModel(project, UriService,
                                                          project.FinanceOperations.Where(predicate).ToArray());

            var exportType = GetExportTypeByName(export);

            if (exportType == null)
            {
                return(View("Operations", viewModel));
            }
            else
            {
                ExportDataService.BindDisplay <User>(user => user?.GetDisplayName());
                var generator = ExportDataService.GetGenerator(exportType.Value, viewModel.Items);
                return(File(
                           await generator.Generate(),
                           generator.ContentType,
                           Path.ChangeExtension("finance-export", generator.FileExtension)
                           ));
            }
        }