public async Task <EventExportFileVm> Handle(GetEventExportQuery request, CancellationToken cancellationToken)
        {
            var allEvents = _mapper.Map <List <EventExportDto> >((await _asyncRepository.ListAllAsync()).OrderBy(x => x.Date));

            var fileData = _csvExporter.ExportEventsToCsv(allEvents);

            var eventExportFileDto = new EventExportFileVm {
                EventExportFileName = $"{Guid.NewGuid()}.csv", ContentType = "text/csv", Data = fileData
            };

            return(eventExportFileDto);
        }
Ejemplo n.º 2
0
        public async Task <TransactionExportVm> Handle(GetTransactionExportQuery request, CancellationToken cancellationToken)
        {
            var result = await _transactionRepository.GetAccountTransactions(request.Id);

            var transactions = _mapper.Map <List <TransactionExportDto> >(result);

            var fileData = _csvExporter.ExportEventsToCsv(transactions);

            var eventExportFileDto = new TransactionExportVm()
            {
                ContentType = "text/csv", Data = fileData, TransactionExportFileName = $"{Guid.NewGuid()}.csv"
            };

            return(eventExportFileDto);
        }