public BuildingUpgradeProductConsolidatorResponse GetConsolidatedProductQueue(BuildingUpgradeProductConsoldatorRequest request)
        {
            if (request==null || request.BuildingUpgrades == null)
                return new BuildingUpgradeProductConsolidatorResponse
                {
                    ConsolidatedTotalProductQueue = new Queue<Product>(),
                    ConsolidatedRequiredProductQueue = new Queue<Product>(new Product[]{}),
                    ConsolidatedRequiredProductsInStorage = new List<Product>(),
                    AvailableStorage = new List<Product>()
                };

            SetupProductTypes(request);

            //get flattened list including the dependencies.
            var combinedProductList = GetFlattenedProductRequirementList(request, null).Products;
            if (!combinedProductList.Any())
                return new BuildingUpgradeProductConsolidatorResponse
                {
                    ConsolidatedRequiredProductQueue = new Queue<Product>(),
                    ConsolidatedTotalProductQueue = new Queue<Product>(),
                    AvailableStorage = new List<Product>(),
                    ConsolidatedRequiredProductsInStorage = new List<Product>()
                };

            //now remove products we have in storage including the dependents.
            var cityStorage = request.CityStorage ?? new CityStorage
            {
                CurrentInventory = new Product[0]
            };
            // Get Required list by flattening the total with city storage.
            var requiredProductList = GetFlattenedProductRequirementList(request, cityStorage).Products;

            //return the list in order by manufacturer type id then by how long to fulfill the item.
            var availableStorageList = GetAvailableStorageList(cityStorage, combinedProductList);
            var requiredInStorage = GetRequiredInStorageList(cityStorage, combinedProductList);

            var ret = new BuildingUpgradeProductConsolidatorResponse
            {
                ConsolidatedRequiredProductQueue = new Queue<Product>(requiredProductList.OrderBy(x => x.ManufacturerTypeId).ThenBy(y => y.TimeToFulfill)),
                ConsolidatedTotalProductQueue = new Queue<Product>(combinedProductList.OrderBy(x => x.ManufacturerTypeId).ThenBy(y => y.TimeToFulfill)),
                AvailableStorage = availableStorageList,
                ConsolidatedRequiredProductsInStorage = requiredInStorage

            };
            return ret;
        }
 public BuildingUpgradeProductConsolidatorResponse GetConsolidatedProductQueue(BuildingUpgradeProductConsoldatorRequest request)
 {
     throw new System.NotImplementedException();
 }
 private void SetupProductTypes(BuildingUpgradeProductConsoldatorRequest request)
 {
     if (request.ProductTypes == null)
         request.ProductTypes = _propertyUpgradeUoW.ProductTypeRepository.Get().Select(Mapper.Map<ProductType>).ToArray();
     _productTypes = request.ProductTypes;
 }
 private RequiredProductFlattenerResponse GetFlattenedProductRequirementList(BuildingUpgradeProductConsoldatorRequest request, CityStorage cityStorage)
 {
     var inventoryFlattenerRequest = new RequiredProductFlattenerRequest
     {
         Products = request.BuildingUpgrades.Where(x=>x.CalculateInBuildingUpgrades).SelectMany(x=>x.Products).ToArray(),
         ProductTypes = _productTypes,
         CityStorage = cityStorage
     };
     return _requiredProductFlattener.GetFlattenedInventory(inventoryFlattenerRequest);
 }