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 GetStatus(List statusIds = null, List statusTypeIds = null) { return WithUnitOfWork(uow => { return uow.StockStatusRepository.ReadStatus(statusIds, statusTypeIds); }); } /// /// 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). /// /// SKU number /// Status ID /// Balance as quantity 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); }); } } }