public List <InventoryRecord> GetInventory(GenericVariant variant) { IList <InventoryRecord> inventoryRecords = _inventoryService.QueryByEntry(new string[] { variant.Code }); return(inventoryRecords.ToList()); }
private IEnumerable <string> GetAvailableSizes(GenericProduct product, GenericVariant entry) { return(product != null && entry != null? _productService.GetVariants(product).OfType <GenericVariant>().Where(x => string.IsNullOrEmpty(x.Color) || string.IsNullOrEmpty(entry.Color) || x.Color.Equals(entry.Color)) .Select(x => x.Size) : Enumerable.Empty <string>()); }
public VariantItemViewModel(GenericVariant variant) { Name = variant.Name; // Price = GetPrice(variant); Color = variant.Color; Size = variant.Size; Images = variant.GetImages(); Code = variant.Code; }
public VariantItemViewModel BuildVariantItem(GenericVariant variant) { var viewModel = new VariantItemViewModel(variant); viewModel.Price = _priceService .GetPrices(variant) .OrderBy(x => x.UnitPrice.Amount) .FirstOrDefault(x => x.ValidFrom.Date <= DateTime.Now) ?.UnitPrice ?? new Mediachase.Commerce.Money(0, "USD"); viewModel.Inventory = _inventoryService .GetInventory(variant) .OrderBy(x => x.PurchaseAvailableQuantity) .FirstOrDefault() ?.PurchaseAvailableQuantity ?? decimal.Zero; return(viewModel); }
private static bool TryGetFashionVariantByColorAndSize(IEnumerable <GenericVariant> variants, string color, string size, out GenericVariant variant) { variant = variants.FirstOrDefault(x => (string.IsNullOrEmpty(color) || x.Color.Equals(color, StringComparison.OrdinalIgnoreCase)) && (string.IsNullOrEmpty(size) || x.Size.Equals(size, StringComparison.OrdinalIgnoreCase))); return(variant != null); }
public List <IPriceDetailValue> GetPrices(GenericVariant variant) { IList <IPriceDetailValue> prices = _priceService.List(variant.ContentLink); return(prices.ToList()); }