private StockStatusCalculatorResult GetStockStatus(Variant variant, string sourceId) { var cartContext = _cartContextAccessor.CartContext; var calculatorArgs = new StockStatusCalculatorArgs { UserSystemId = _securityContextService.GetIdentityUserSystemId().GetValueOrDefault(), SourceId = sourceId, CountrySystemId = _countryService.Get(cartContext?.CountryCode)?.SystemId }; var calculatorItemArgs = new StockStatusCalculatorItemArgs { VariantSystemId = variant.SystemId, Quantity = decimal.One }; return(_stockStatusCalculator.GetStockStatuses(calculatorArgs, calculatorItemArgs).TryGetValue(variant.SystemId, out StockStatusCalculatorResult calculatorResult) ? calculatorResult : null); }
private StockStatusCalculatorResult GetStockStatus(Variant variant, string sourceId) { var calculatorArgs = new StockStatusCalculatorArgs { Date = HttpContext.Current?.Timestamp ?? DateTime.UtcNow, UserSystemId = SecurityToken.CurrentSecurityToken.UserID, WebSiteSystemId = _cartAccessor.Cart.OrderCarrier.WebSiteID, SourceId = sourceId, CountrySystemId = _cartAccessor.Cart.OrderCarrier.CountryID }; var calculatorItemArgs = new StockStatusCalculatorItemArgs { VariantSystemId = variant.SystemId, Quantity = decimal.One }; return(_stockStatusCalculator.GetStockStatuses(calculatorArgs, calculatorItemArgs).TryGetValue(variant.SystemId, out StockStatusCalculatorResult calculatorResult) ? calculatorResult : null); }
public StockStatusCalculatorResult Populate(StockStatusCalculatorArgs calculatorArgs, StockStatusCalculatorItemArgs calculatorItemArgs, StockStatusCalculatorResult result) { var key = (calculatorItemArgs.Quantity == 0 ? result.InStockQuantity > 0 : result.InStockQuantity >= calculatorItemArgs.Quantity) ? "stock.instockwithoutquantity" : "stock.outofstockwithoutquantity"; var channel = _routeRequestLookupInfoAccessor.RouteRequestLookupInfo?.Channel; if (channel?.WebsiteSystemId != null) { var website = _websiteService.Get(channel.WebsiteSystemId.Value); var value = website.Texts.GetValue(key, CultureInfo.CurrentUICulture); if (value != null) { result.Description = string.Format(value, result.InStockQuantity); } } if (result.Description == null) { string value = _stringLocalizer.GetString(key); if (value != null) { result.Description = string.Format(value, result.InStockQuantity); } } if (result.Description == null) { result.Description = result.InStockQuantity.ToString(); } return(result); }