From 94041ae33bed4d25f40c55e024e914b57742d433 Mon Sep 17 00:00:00 2001 From: Aleksandr Shinkarev Date: Sat, 8 Nov 2025 15:48:27 +0500 Subject: [PATCH 1/2] chore: add testing temp code duplication --- Application/Commands/CreateItemCommand.cs | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Application/Commands/CreateItemCommand.cs b/Application/Commands/CreateItemCommand.cs index 91ba52e..f2aecf3 100644 --- a/Application/Commands/CreateItemCommand.cs +++ b/Application/Commands/CreateItemCommand.cs @@ -66,4 +66,36 @@ await _context return item.Id; } + + public async Task ExecuteDuplicationAsync(CreateItemCommandParams createItemCommandParams) + { + var itemTypeIdDoesNotExistWithinTenant = await _context + .QueryableWithinTenant() + .AllAsync(x => x.Id != createItemCommandParams.ItemTypeId); + + if (itemTypeIdDoesNotExistWithinTenant) + { + throw new Exception($"Passed item type where id={createItemCommandParams.ItemTypeId} is not found within tenant where id={_claimsProvider.TenantId}"); + } + + var item = new Item + { + TenantId = _claimsProvider.TenantId, + Name = createItemCommandParams.Name, + SerialNumber = createItemCommandParams.SerialNumber, + ItemTypeId = createItemCommandParams.ItemTypeId, + Price = createItemCommandParams.Price, + Description = createItemCommandParams.Description, + PurchaseDate = createItemCommandParams.PurchaseDate, + HolderEmployeeId = createItemCommandParams.HolderEmployeeId + }; + + await _context + .Items + .AddAsync(item); + + await _context.SaveChangesAsync(); + + return item.Id; + } } From a776e8aba609798024848e298a16eb5738c4b860 Mon Sep 17 00:00:00 2001 From: Aleksandr Shinkarev Date: Sat, 8 Nov 2025 16:04:20 +0500 Subject: [PATCH 2/2] chore: add testing temp code 2nd duplication --- Application/Commands/CreateItemCommand.cs | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Application/Commands/CreateItemCommand.cs b/Application/Commands/CreateItemCommand.cs index f2aecf3..d9ffdf3 100644 --- a/Application/Commands/CreateItemCommand.cs +++ b/Application/Commands/CreateItemCommand.cs @@ -98,4 +98,36 @@ await _context return item.Id; } + + public async Task ExecuteDuplication2Async(CreateItemCommandParams createItemCommandParams) + { + var itemTypeIdDoesNotExistWithinTenant = await _context + .QueryableWithinTenant() + .AllAsync(x => x.Id != createItemCommandParams.ItemTypeId); + + if (itemTypeIdDoesNotExistWithinTenant) + { + throw new Exception($"Passed item type where id={createItemCommandParams.ItemTypeId} is not found within tenant where id={_claimsProvider.TenantId}"); + } + + var item = new Item + { + TenantId = _claimsProvider.TenantId, + Name = createItemCommandParams.Name, + SerialNumber = createItemCommandParams.SerialNumber, + ItemTypeId = createItemCommandParams.ItemTypeId, + Price = createItemCommandParams.Price, + Description = createItemCommandParams.Description, + PurchaseDate = createItemCommandParams.PurchaseDate, + HolderEmployeeId = createItemCommandParams.HolderEmployeeId + }; + + await _context + .Items + .AddAsync(item); + + await _context.SaveChangesAsync(); + + return item.Id; + } }