public BankAccountMovementImport GetBankAccountMovementImport(BankAccountMovementImportType importType) { switch (importType) { case BankAccountMovementImportType.CGD: return(new BankAccountMovementImportCgd()); case BankAccountMovementImportType.BPI: return(new BankAccountMovementImportBpi()); default: return(null); } }
public List <BankAccountMovement> ImportBankAccountMovement(string userId, long bankAccountId, BankAccountMovementImportType importType, IFormFile file) { factory = factory ?? new BankAccountMovementImportFactory(); BankAccountMovementImport import = factory.GetBankAccountMovementImport(importType); List <BankAccountMovement> lines = import.GetBankAccountMovements(file); List <BankAccountMovement> linesToRemove = new List <BankAccountMovement>(); foreach (var item in lines) { if (myFinanceRepo.ExistsBankAccountMovements(bankAccountId, item)) { linesToRemove.Add(item); } } lines.RemoveAll(x => linesToRemove.Any(q => q.GetHashCode() == x.GetHashCode())); return(lines); }