private void Execute(int year, int month, string accountName, string filePath)
        {
            var account = _accountService.Get(accountName);

            if (account == null)
            {
                _outputWriter.WriteErrorLine($"Unknown account name: {accountName}");
                return;
            }

            _csvService.GetCsvData(year, month, account.Name, filePath)
            .Tabulate(_outputWriter, true, 0);
        }
        private void Execute(int year, int month, string accountName, string filePath)
        {
            var account = _accountService.Get(accountName);

            if (account == null)
            {
                _outputWriter.WriteErrorLine($"Unknown account name: {accountName}");
                return;
            }
            var mappedData = _csvService.GetCsvData(year, month, account.Name, filePath, true).ToList();

            _transactionService.Clear(year, month, account.Name);
            _transactionService.Put(mappedData);
            _outputWriter.WriteLine("Unmapped Transactions:");
            _outputWriter.WriteLine("");
            mappedData.Where(t => string.IsNullOrEmpty(t.Category))
            .Tabulate(_outputWriter, true, 0);
        }
Exemple #3
0
        public IActionResult UploadFiles(int year, int month, string accountName)

        {
            var files = Request.Form.Files;

            if (files.Count != 1)
            {
                return(BadRequest("Please supply one, and only one, CSV file to process"));
            }
            using (var stream = files[0].OpenReadStream())
            {
                var transactions = _csvService.GetCsvData(year, month, accountName, stream, files[0].FileName, true).ToList();
                _transactionService.Clear(year, month, accountName);
                _transactionService.Put(transactions);
                return(Ok(new
                {
                    Mapped = transactions.Where(t => !string.IsNullOrEmpty(t.Category)),
                    Unmapped = transactions.Where(t => string.IsNullOrEmpty(t.Category))
                }));
            }
        }