mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-21 07:17:15 +00:00
48 lines
1.7 KiB
C#
48 lines
1.7 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 StockStatusService : UnitOfWorkBase
|
|
{
|
|
public StockStatusService() : base() { }
|
|
|
|
internal StockStatusService(IUnitOfWork unitOfWork) : base(unitOfWork) { }
|
|
|
|
public Dictionary<int, Model.Stock.Status> GetStatus(List<int> statusIds = null, List<int> statusTypeIds = null)
|
|
{
|
|
return WithUnitOfWork(uow =>
|
|
{
|
|
return uow.StockStatusRepository.ReadStatus(statusIds, statusTypeIds);
|
|
});
|
|
}
|
|
|
|
/// <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);
|
|
});
|
|
}
|
|
|
|
|
|
}
|
|
}
|