public async Task ImportAndMergeBankStatementAsync(string storageKey, Account account)
{
if (storageKey.IsNothing())
{
throw new ArgumentNullException(nameof(storageKey));
}
if (account == null)
{
throw new ArgumentNullException(nameof(account));
}
if (StatementModel == null)
{
throw new InvalidOperationException(
"There are no transactions loaded, you must first load an existing file or create a new one.");
}
var additionalModel = await this.statementRepository.ImportBankStatementAsync(storageKey, account);
var combinedModel = StatementModel.Merge(additionalModel);
IEnumerable<IGrouping<int, Transaction>> duplicates = combinedModel.ValidateAgainstDuplicates();
if (duplicates.Count() == additionalModel.AllTransactions.Count())
{
throw new TransactionsAlreadyImportedException();
}
StatementModel.Dispose();
StatementModel = combinedModel;
NewDataAvailable();
}