Skip to content

Commit

Permalink
fix: give error when no accounts to add (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
amiralirahimii authored Sep 9, 2024
1 parent 7f1e22c commit d74e852
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Application/Services/DomainService/AccountService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public async Task<Result> AddAccountsFromCsvAsync(string filePath, long fileId)
var existingAccountIds = await _accountRepository.GetAllIdsAsync();
var newAccounts = accounts.Where(a => !existingAccountIds.Contains(a.AccountId)).ToList();

if(newAccounts.Count == 0)
{
return Result.Fail(ErrorCode.BadRequest, "No new accounts to add");
}

var fileAlreadyExists = await _fileIdRepository.IdExistsAsync(fileId);
if (fileAlreadyExists)
{
Expand Down

0 comments on commit d74e852

Please sign in to comment.