From d74e8522034a5766f6bd710b7eaade6ab19047f1 Mon Sep 17 00:00:00 2001 From: Amirali Rahimi Date: Mon, 9 Sep 2024 02:44:22 -0400 Subject: [PATCH] fix: give error when no accounts to add (#38) --- 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) {