Example #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));
        }
        public async Task <ActionResult> SummaryByMaster(string token, int projectId)
        {
            var project = await ProjectRepository.GetProjectWithFinances(projectId);

            var guid = new Guid(token.FromHexString());

            var acl = project.ProjectAcls.SingleOrDefault(a => a.Token == guid);

            if (acl == null)
            {
                return(Content("Unauthorized"));
            }

            var masterOperations = project.FinanceOperations.ToArray();

            var masterTransfers = await FinanceReportRepository.GetAllMoneyTransfers(projectId);

            var summary =
                MasterBalanceBuilder.ToMasterBalanceViewModels(masterOperations, masterTransfers, projectId);

            var generator = ExportDataService.GetGenerator(ExportType.Csv, summary,
                                                           new MoneySummaryByMasterExporter(UriService));

            return(await ReturnExportResult(project.ProjectName + ": " + "money-summary", generator));
        }
Example #3
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 = ExportTypeNameParserHelper.ToExportType(export);

            if (exportType == null)
            {
                return(View("Operations", viewModel));
            }
            else
            {
                var frontend = new FinanceOperationExporter(project, UriService);

                var generator = ExportDataService.GetGenerator(exportType.Value, viewModel.Items, frontend);

                var fileName = project.ProjectName + ": Финансы";

                return(File(await generator.Generate(), generator.ContentType,
                            Path.ChangeExtension(fileName.ToSafeFileName(), generator.FileExtension)));
            }
        }
Example #4
0
        protected Task <FileContentResult> ExportWithCustomFronend <T>(IEnumerable <T> viewModel, string title,
                                                                       ExportType exportType, IGeneratorFrontend frontend, string projectName)
        {
            var generator = ExportDataService.GetGenerator(exportType, viewModel,
                                                           frontend);

            return(ReturnExportResult(projectName + ": " + title, generator));
        }
Example #5
0
        private async Task <FileContentResult> ExportWithCustomFrontend(
            IEnumerable <ClaimListItemViewModel> viewModel, string title,
            ExportType exportType, IGeneratorFrontend <ClaimListItemViewModel> frontend, string projectName)
        {
            var generator = ExportDataService.GetGenerator(exportType, viewModel,
                                                           frontend);

            var fileName = projectName + ": " + title;

            return(File(await generator.Generate(), generator.ContentType,
                        Path.ChangeExtension(fileName.ToSafeFileName(), generator.FileExtension)));
        }
        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)
                           ));
            }
        }