public ProductVariantViewModel(VariationContent variationContent)
 {
     this._variationContent = variationContent;
     _isAvailable = _variationContent.IsPendingPublish == false &&
                 _variationContent.IsDeleted == false &&
                 _variationContent.IsAvailableInCurrentMarket();
 }
 public ProductVariantViewModel(VariationContent variationContent)
 {
     this._variationContent = variationContent;
     _isAvailable           = _variationContent.IsPendingPublish == false &&
                              _variationContent.IsDeleted == false &&
                              _variationContent.IsAvailableInCurrentMarket();
 }
        private Lazy <IEnumerable <WarehouseInventoryViewModel> > GetAllWarehouseInventory(VariationContent catalogContent)
        {
            //make sure we don't get any null reference exception when accessing Inventories.
            var inventories           = Enumerable.Empty <Inventory>();
            var allWarehouseInventory = new List <WarehouseInventoryViewModel>();

            if (catalogContent != null && catalogContent.IsAvailableInCurrentMarket())
            {
                inventories = catalogContent.GetStockPlacement(InventoryLoader);
            }

            if (inventories.Count() > 0)
            {
                foreach (Inventory inventory in inventories)
                {
                    var warehouse = WarehouseHelper.GetWarehouse(inventory.WarehouseCode);
                    if (warehouse != null && warehouse.IsActive)
                    {
                        WarehouseInventoryViewModel model = new WarehouseInventoryViewModel()
                        {
                            WarehouseCode    = warehouse.Code,
                            WarehouseName    = HttpUtility.HtmlEncode(warehouse.Name),
                            WarehouseContact = HttpUtility.HtmlEncode(string.Format("{0} - {1}", warehouse.ContactInformation.FullName,
                                                                                    warehouse.ContactInformation.Email)),
                            WarehouseAddress = HttpUtility.HtmlEncode(string.Format("{0} {1}", warehouse.ContactInformation.Line1,
                                                                                    warehouse.ContactInformation.City))
                        };
                        model.InStockLevel  = inventory.InStockQuantity;
                        model.ReservedLevel = inventory.ReservedQuantity;
                        model.IsAvailable   = (inventory.InStockQuantity - inventory.ReservedQuantity > 0);

                        allWarehouseInventory.Add(model);
                    }
                }
            }

            return(new Lazy <IEnumerable <WarehouseInventoryViewModel> >(() => allWarehouseInventory));
        }