Example #1
0
        public static string SizeCorrection(string size, string styleSize)
        {
            if (size == "X-Small" ||
                size == "XSmall" ||
                size == "XS"

                || size == "Small" ||
                size == "S"

                || size == "Medium" ||
                size == "M"

                || size == "Large" ||
                size == "L"

                || size == "X-Large" ||
                size == "XLarge" ||
                size == "XL"

                || size == "2X-Large" ||
                size == "2XLarge" ||
                size == "XXLarge" ||
                size == "2XL" ||
                size == "XXL"

                || size == "3X-Large" ||
                size == "3XLarge" ||
                size == "XXXLarge" ||
                size == "3XL" ||
                size == "XXXL")
            {
                var hasDisit = SizeHelper.GetFirstNumber(styleSize) > 0;
                if (hasDisit)
                {
                    return(size + " / " + styleSize.Replace("/", "-"));
                }
            }
            return(size);
        }
Example #2
0
        public static IList <int> GetBreakdowns(List <string> sizes)
        {
            var breakdowns = new List <int>();

            if (sizes.Count < 1)
            {
                return(null);
            }

            //b.	If sizes 4,6,8,10 or 4/5, 6/6x, 7/8, 10/12 or 4/5, 6/7, 8, 10/12 1-2-2-1
            if (sizes.Count == 4 &&
                (sizes.All(s => s == "4" ||
                           s == "6" ||
                           s == "8" ||
                           s == "10") ||
                 sizes.All(s => s == "4/5" ||
                           s == "6/6x" ||
                           s == "7/8" ||
                           s == "10/12") ||
                 sizes.All(s => s == "4/5" ||
                           s == "6/7" ||
                           s == "8" ||
                           s == "10/12") ||
                 sizes.All(s => s == "4/5" ||
                           s == "6" ||
                           s == "7/8" ||
                           s == "10/12")))
            {
                var firstSize = sizes.FirstOrDefault(s => s == "4/5" || s == "4");
                var lastSize  = sizes.FirstOrDefault(s => s == "10/12" || s == "10");
                if (firstSize != null && lastSize != null)
                {
                    var otherSizes = sizes.Where(s => s != firstSize && s != lastSize).ToList();
                    if (otherSizes.Count() == 2)
                    {
                        foreach (var size in sizes)
                        {
                            if (size == firstSize || size == lastSize)
                            {
                                breakdowns.Add(1);
                            }
                            else
                            {
                                breakdowns.Add(2);
                            }
                        }
                        return(breakdowns);
                    }
                }
            }

            if (sizes.Count == 4 &&
                (sizes.All(s => s == "6" ||
                           s == "7/8" ||
                           s == "10/12" ||
                           s == "14/16") ||
                 sizes.All(s => s == "6/6x" ||
                           s == "7/8" ||
                           s == "10/12" ||
                           s == "14/16")))
            {
                var firstSize = sizes.FirstOrDefault(s => s == "6" || s == "6/6x");
                var lastSize  = sizes.FirstOrDefault(s => s == "14/16");
                if (firstSize != null && lastSize != null)
                {
                    var otherSizes = sizes.Where(s => s != firstSize && s != lastSize).ToList();
                    if (otherSizes.Count() == 2)
                    {
                        foreach (var size in sizes)
                        {
                            if (size == firstSize || size == lastSize)
                            {
                                breakdowns.Add(1);
                            }
                            else
                            {
                                breakdowns.Add(2);
                            }
                        }
                        return(breakdowns);
                    }
                }
            }

            var sortedSizes = sizes.OrderBy(s => SizeHelper.GetSizeIndex(s)).ToList();
            var minSize     = sortedSizes.FirstOrDefault();
            var maxSize     = sortedSizes.LastOrDefault();

            //If sizes are 4-[any]-10 or 6-[any]-12, put default breakdown 1-2-2-1.
            if (sizes.Count == 4)
            {
                if ((minSize == "4" && maxSize == "10") ||
                    (minSize == "6" && maxSize == "12"))
                {
                    foreach (var size in sizes)
                    {
                        if (size == "4" || size == "6")
                        {
                            breakdowns.Add(1);
                        }
                        else if (size == "10" || size == "12")
                        {
                            breakdowns.Add(1);
                        }
                        else
                        {
                            breakdowns.Add(2);
                        }
                    }
                    return(breakdowns);
                }
            }

            //For sizes 4-[any]-8 (just 3 sizes) default breakdown 2-3-1.
            if (sizes.Count == 3)
            {
                //a.	If sizes 2T-4T only, 2-2-2
                if (sizes.All(s => s == "2T" ||
                              s == "3T" ||
                              s == "4T"))
                {
                    breakdowns.Add(2);
                    breakdowns.Add(2);
                    breakdowns.Add(2);
                    return(breakdowns);
                }

                if (minSize == "4" &&
                    maxSize == "8")
                {
                    foreach (var size in sizes)
                    {
                        if (size == "4")
                        {
                            breakdowns.Add(2);
                        }
                        else if (size == "8")
                        {
                            breakdowns.Add(1);
                        }
                        else
                        {
                            breakdowns.Add(3);
                        }
                    }
                    return(breakdowns);
                }

                if (minSize == "4/5" &&
                    maxSize == "8")
                {
                    foreach (var size in sizes)
                    {
                        breakdowns.Add(2);
                    }
                    return(breakdowns);
                }
            }

            //For 5-sizes 4/5 - 14/16: 1-1-2-1-1
            if (sizes.Count == 5)
            {
                var middleSize = sortedSizes[2];
                if (minSize == "4/5" &&
                    maxSize == "14/16")
                {
                    foreach (var size in sizes)
                    {
                        if (size == middleSize)
                        {
                            breakdowns.Add(2);
                        }
                        else
                        {
                            breakdowns.Add(1);
                        }
                    }
                    return(breakdowns);
                }
            }

            //For 6-sizes 4-16: 1-2-2-2-1-1
            if (sizes.Count == 6)
            {
                var preMaxSize = sortedSizes[4];
                if (minSize == "4" &&
                    maxSize == "14")
                {
                    foreach (var size in sizes)
                    {
                        if (size == minSize ||
                            size == maxSize ||
                            size == preMaxSize)
                        {
                            breakdowns.Add(1);
                        }
                        else
                        {
                            breakdowns.Add(2);
                        }
                    }
                    return(breakdowns);
                }
            }

            return(null);
        }