/// <summary> /// Gets the specified product stock. /// </summary> /// <param name="stockInfo">The stock info.</param> /// <param name="args">The arguments.</param> /// <returns>The product stock.</returns> public ProductStock Get(ProductStockInfo stockInfo, ServiceClientArgs args) { SiteContext site = Utils.GetExistingSiteContext(args); using (new SiteContextSwitcher(site)) { IProductStockManager stockManager = Context.Entity.Resolve <IProductStockManager>(); return(stockManager.GetStock(stockInfo)); } }
/// <summary> /// Gets the stock. /// </summary> /// <param name="productId">The product id.</param> /// <returns>The stock.</returns> public long GetStock(string productId) { if (string.IsNullOrEmpty(productId)) { return(0); } long stockValue = 0; try { IProductStockManager stockManager = Context.Entity.Resolve <IProductStockManager>(); ProductStock stock = stockManager.GetStock(new ProductStockInfo { ProductCode = productId }); stockValue = stock.Stock; } catch (Exception ex) { Log.Error("Unable to resolve stock value.", ex, this); } return(stockValue); }