コード例 #1
0
            private static XDesign_FabricStyle XDesign_FabricStyle(MDesign_FabricStyle mFabricStyle)
            {
                var result = new XDesign_FabricStyle()
                {
                    sku   = mFabricStyle.Sku,
                    color = XDesign_Color(mFabricStyle.Color)
                };

                return(result);
            }
コード例 #2
0
        private static FabricStyle CreateFabricStyle(XDesign_FabricStyle xFabricStyle)
        {
            var result = new FabricStyle(xFabricStyle.sku, CreateColor(xFabricStyle.color));

            return(result);
        }
コード例 #3
0
        public async Task <XDesign_FabricStyleCatalog> GetFabricStyleCatalogAsync()
        {
            using var log = BeginFunction(nameof(DesignAjaxService), nameof(GetFabricStyleCatalogAsync));
            try
            {
                var svcFabricStyleCatalogData = await DesignMicroService.GetFabricStyles().ConfigureAwait(false);

                //using var ctx = QuiltContextFactory.Create();

                //var inventoryItems = await (from ii in ctx.InventoryItems
                //                            where ii.InventoryItemTypeCode == InventoryItemTypes.Fabric && (ii.Quantity - ii.ReservedQuantity) > 0
                //                            orderby ii.Hue, ii.Saturation, ii.Value
                //                            select ii).ToListAsync().ConfigureAwait(false)

                //var tags = await (from iit in ctx.InventoryItemTags
                //                  join t in ctx.Tags on iit.TagId equals t.TagId
                //                  select new { iit.InventoryItemId, t.TagTypeCode, t.Value }).ToListAsync().ConfigureAwait(false)

                //var manufacturerNames = new Dictionary<long, string>();
                //var collectionNameSets = new Dictionary<long, List<string>>();
                //foreach (var tag in tags)
                //{
                //    var inventoryItem = inventoryItems.Where(ii => ii.InventoryItemId == tag.InventoryItemId).SingleOrDefault();
                //    if (inventoryItem != null)
                //    {
                //        // Note: assumes an inventory item is associated with only one manufacturer.
                //        //
                //        if (tag.TagTypeCode == TagTypes.Manufacturer)
                //        {
                //            manufacturerNames[tag.InventoryItemId] = tag.Value;
                //        }

                //        if (tag.TagTypeCode == TagTypes.Collection)
                //        {
                //            if (!collectionNameSets.TryGetValue(tag.InventoryItemId, out var collectionNameSet))
                //            {
                //                collectionNameSet = new List<string>();
                //                collectionNameSets[tag.InventoryItemId] = collectionNameSet;
                //            }
                //            collectionNameSet.Add(tag.Value);
                //        }
                //    }
                //}

                //var manufacturers = new Dictionary<string, Design_FabricStyleManufacturerData>();
                //var collectionSets = new Dictionary<Design_FabricStyleManufacturerData, List<Design_FabricStyleCollectionData>>();
                //var fabricSets = new Dictionary<Design_FabricStyleCollectionData, List<Design_FabricStyleData>>();

                //foreach (var inventoryItem in inventoryItems)
                //{
                //    var manufacturerName = manufacturerNames[inventoryItem.InventoryItemId];
                //    var collectionNameSet = collectionNameSets[inventoryItem.InventoryItemId];

                //    if (!manufacturers.TryGetValue(manufacturerName, out var manufacturer))
                //    {
                //        manufacturer = new Design_FabricStyleManufacturerData()
                //        {
                //            manufacturerName = manufacturerName
                //        };
                //        manufacturers[manufacturerName] = manufacturer;

                //        collectionSets[manufacturer] = new List<Design_FabricStyleCollectionData>();
                //    }

                //    var collectionSet = collectionSets[manufacturer];
                //    foreach (var collectionName in collectionNameSet)
                //    {
                //        var collection = collectionSet.Where(r => r.collectionName == collectionName).SingleOrDefault();
                //        if (collection == null)
                //        {
                //            collection = new Design_FabricStyleCollectionData()
                //            {
                //                collectionName = collectionName
                //            };
                //            collectionSet.Add(collection);

                //            fabricSets[collection] = new List<Design_FabricStyleData>();
                //        }

                //        var fabricSet = fabricSets[collection];
                //        var color = Color.FromAhsb(255, inventoryItem.Hue, inventoryItem.Saturation / 100.0, inventoryItem.Value / 100.0);
                //        var fabricStyle = new FabricStyle(inventoryItem.Sku, color);
                //        fabricSet.Add(Implementations.ServiceDataFactory.CreateFabricStyleData(fabricStyle));
                //    }
                //}

                //foreach (var collection in fabricSets.Keys)
                //{
                //    collection.fabricStyles = fabricSets[collection].ToArray();
                //}
                //foreach (var manufacturer in collectionSets.Keys)
                //{
                //    manufacturer.collections = collectionSets[manufacturer].ToArray();
                //}

                var manufacturers = new List <XDesign_FabricStyleManufacturer>();
                foreach (var svcManufacturer in svcFabricStyleCatalogData.Manufacturers)
                {
                    var collections = new List <XDesign_FabricStyleCollection>();
                    foreach (var svcCollection in svcManufacturer.Collections)
                    {
                        var fabricStyles = new List <XDesign_FabricStyle>();
                        foreach (var svcFabricStyle in svcCollection.FabricStyles)
                        {
                            var fabricStyle = new XDesign_FabricStyle()
                            {
                                color = new XDesign_Color()
                                {
                                    webColor = svcFabricStyle.Color.WebColor
                                },
                                sku = svcFabricStyle.Sku
                            };
                            fabricStyles.Add(fabricStyle);
                        }

                        var collection = new XDesign_FabricStyleCollection()
                        {
                            collectionName = svcCollection.CollectionName,
                            fabricStyles   = fabricStyles.ToArray()
                        };
                        collections.Add(collection);
                    }

                    var manufacturer = new XDesign_FabricStyleManufacturer()
                    {
                        manufacturerName = svcManufacturer.ManufacturerName,
                        collections      = collections.ToArray()
                    };
                    manufacturers.Add(manufacturer);
                }

                var result = new XDesign_FabricStyleCatalog()
                {
                    manufacturers = manufacturers.ToArray()
                };

                log.Result(result);
                return(result);
            }
            catch (Exception ex)
            {
                log.Exception(ex);
                throw;
            }
        }