Exemple #1
0
            public async Task <FileResult> Handle(GetFilteredTransactionsQuery query, CancellationToken cancellationToken)
            {
                var transactionList = await _context.Transactions.ToListAsync();

                if (!String.IsNullOrEmpty(query.ClientName))
                {
                    transactionList = transactionList.Where(a => a.ClientName == query.ClientName).ToList();
                }
                if (!String.IsNullOrEmpty(query.Type))
                {
                    transactionList = transactionList.Where(a => a.Type == query.Type).ToList();
                }
                if (!String.IsNullOrEmpty(query.Status))
                {
                    transactionList = transactionList.Where(a => a.Status == query.Status).ToList();
                }

                if (transactionList == null)
                {
                    return(null);
                }
                ExcelFileCreator.CreateExcelFile(transactionList);
                return(new PhysicalFileResult("Excel.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
                {
                    FileDownloadName = "export.xlsx"
                });
            }
            public async Task <FileResult> Handle(GetAllTransactionsQuery query, CancellationToken cancellationToken)
            {
                var transactionList = await _context.Transactions.ToListAsync();

                if (transactionList == null)
                {
                    return(null);
                }
                ExcelFileCreator.CreateExcelFile(transactionList);
                return(new VirtualFileResult("Excel.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
                {
                    FileDownloadName = "export.xlsx"
                });
            }