public IActionResult UploadFromCsv() { ReadCsv csvReader = new ReadCsv(); var allLinks = csvReader.result; LoadCsv csvLoader = new LoadCsv(allLinks, _itemData); return(RedirectToAction(nameof(List))); }
static void ConvertLetterWritingAddresses(List <string> args) { Console.WriteLine("Convert Letter Writing Addresses"); if (args.Count < 3) { throw new NormalException("Not enough arguments! Usage: alba covert-addresses <letter-writing-csv-input-file> <alba-tsv-output-file>"); } string inputPath = args[1]; string outputPath = args[2]; Console.WriteLine($"Input File Path: {inputPath}"); Console.WriteLine($"Output File Path: {outputPath}"); var writingAddresses = LoadCsv <LetterWritingSheet> .LoadFrom(inputPath); var albaAddresses = new List <AlbaAddressExport>(); var errors = new List <LetterWritingSheet>(); foreach (var a in writingAddresses) { try { albaAddresses.Add( new AlbaAddressExport { Address = a.Address, Suite = a.Suite, City = a.City, Postal_code = a.ZIP, Province = a.State, } ); } catch (Exception e) { errors.Add(a); Console.WriteLine(e.Message); } } if (errors.Count > 0) { Console.WriteLine(); Console.WriteLine("Errors:"); foreach (var a in errors) { Console.WriteLine(a.Address); } Console.WriteLine($"Count: {errors.Count}"); } LoadTsvAlbaAddresses.SaveTo(albaAddresses, outputPath); LoadCsv <LetterWritingSheet> .SaveTo(errors, $"{outputPath}.errors.txt"); }