mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-19 14:37:16 +00:00
45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
using bnhtrade.Core.Data.Database.UnitOfWork;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace bnhtrade.Core.Logic.Inventory
|
|
{
|
|
public class StockJournalService : UnitOfWorkBase
|
|
{
|
|
public StockJournalService() { }
|
|
|
|
internal StockJournalService(IUnitOfWork unitOfWork) : base(unitOfWork) { }
|
|
|
|
public void StockJournalDelete(int stockJournalId)
|
|
{
|
|
WithUnitOfWork(uow =>
|
|
{
|
|
if (stockJournalId <= 0)
|
|
{
|
|
throw new ArgumentException("Stock journal ID must be greater than zero", nameof(stockJournalId));
|
|
}
|
|
uow.StockJournalRepository.StockJournalDelete(stockJournalId);
|
|
CommitIfOwned(uow);
|
|
});
|
|
}
|
|
|
|
// can be used before commiting an sql insert, update or delete to the stock journal to ensure a status does not fall below 0
|
|
// (unless the status is enabled to do so)
|
|
// set empty list or statusIdEffected to null to check entier stock entries for consistency
|
|
public bool WIP_StockJournalConsistencyCheck(int stockId, List<int> statusIdEffected = null)
|
|
{
|
|
return WithUnitOfWork(uow =>
|
|
{
|
|
if (stockId <= 0)
|
|
{
|
|
throw new ArgumentException("Stock ID must be greater than zero", nameof(stockId));
|
|
}
|
|
return uow.StockJournalRepository.WIP_StockJournalConsistencyCheck(stockId, statusIdEffected);
|
|
});
|
|
}
|
|
}
|
|
}
|