Пример #1
0
        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>());
 }
Пример #3
0
 public VariantItemViewModel(GenericVariant variant)
 {
     Name = variant.Name;
     // Price = GetPrice(variant);
     Color  = variant.Color;
     Size   = variant.Size;
     Images = variant.GetImages();
     Code   = variant.Code;
 }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        public List <IPriceDetailValue> GetPrices(GenericVariant variant)
        {
            IList <IPriceDetailValue> prices = _priceService.List(variant.ContentLink);

            return(prices.ToList());
        }