wip, this turned into a maaaaaahooosive job

This commit is contained in:
2025-07-09 13:28:17 +01:00
parent 8c3b00c75c
commit c0f7f1a476
25 changed files with 1888 additions and 1188 deletions
@@ -0,0 +1,47 @@
using bnhtrade.Core.Data.Database.UnitOfWork;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Transactions;
using System.Windows.Forms;
namespace bnhtrade.Core.Logic.Inventory
{
public class SkuService : UnitOfWorkBase
{
public SkuService() : base() { }
internal SkuService(IUnitOfWork unitOfWork) : base(unitOfWork) { }
/// <summary>
/// Used for retriving an SKU ID by parameters. If no match, can create a new SKU if required.
/// </summary>
/// <param name="productId">The product Id for the SKU</param>
/// <param name="conditionId">The condition Id for the SKU</param>
/// <param name="accountTaxCodeId">The tax code Id for the SKU</param>
/// <param name="noMatchCreateNew">When set to true, if no match is made, function will create a new sku and return the id for that</param>
/// <returns>Return the id for the new or existing sku or, dependant on set parameters, 0 if not found</returns>
/// <exception cref="Exception"></exception>
public int GetSkuId(int productId, int conditionId, int accountTaxCodeId, bool noMatchCreateNew)
{
return WithUnitOfWork(uow =>
{
int? skuId = uow.SkuRepository.ReadSkuId(productId, conditionId, accountTaxCodeId);
if (skuId != null)
{
return (int)skuId;
}
else if (noMatchCreateNew == false)
{
return 0;
}
else
{
int newSkuId = uow.SkuRepository.InsertNewSku(productId, conditionId, accountTaxCodeId);
CommitIfOwned(uow);
return newSkuId;
}
});
}
}
}