From add8bab689ead127f7e25bd35bf958f8354bd455 Mon Sep 17 00:00:00 2001 From: amiralirahimii Date: Mon, 9 Sep 2024 10:12:40 +0330 Subject: [PATCH] fix: give error when no accounts to add --- src/Application/Services/DomainService/AccountService.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Application/Services/DomainService/AccountService.cs b/src/Application/Services/DomainService/AccountService.cs index 58347f2..c999259 100644 --- a/src/Application/Services/DomainService/AccountService.cs +++ b/src/Application/Services/DomainService/AccountService.cs @@ -35,6 +35,11 @@ public async Task 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) {