mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-21 07:17:15 +00:00
wip, this turned into a maaaaaahooosive job
This commit is contained in:
39
src/bnhtrade.Core/Logic/Inventory/StockStatusService.cs
Normal file
39
src/bnhtrade.Core/Logic/Inventory/StockStatusService.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
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 StockStatusService : UnitOfWorkBase
|
||||
{
|
||||
public StockStatusService() : base() { }
|
||||
|
||||
internal StockStatusService(IUnitOfWork unitOfWork) : base(unitOfWork) { }
|
||||
|
||||
/// <summary>
|
||||
/// Return the avaliable balance of a status. Uses a more efficent sql/code. However, balance requests should
|
||||
/// generally also involve a date/time (i.e. the system does allow a stock transaction in the future, therefore
|
||||
/// this method may give an available quantity, but transfers before that date wouod not be possible).
|
||||
/// </summary>
|
||||
/// <param name="sku">SKU number</param>
|
||||
/// <param name="statusId">Status ID</param>
|
||||
/// <returns>Balance as quantity</returns>
|
||||
private int GetAvailableBalanceBySku(string sku, int statusId)
|
||||
{
|
||||
return WithUnitOfWork(uow =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(sku))
|
||||
{
|
||||
throw new ArgumentException("SKU number is null, empty, or whitespace", nameof(sku));
|
||||
}
|
||||
|
||||
return uow.StockJournalRepository.ReadStatusBalanceBySku(sku, statusId);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user