public static bool VerifyAndSetSeasonsAndEventTypes(HashSet <int> seasons, HashSet <int> eventTypes, Combination comb) { PreOutfit po = new PreOutfit(); po.Combination = comb; return(VerifyAndSetSeasonsAndEventTypes(seasons, eventTypes, po)); }
public void CanMatchSeasons() { HashSet <int> seasons = new HashSet <int>(); HashSet <int> eventTypes = new HashSet <int>(); PreOutfit po = new PreOutfit(); Combination c = new Combination(); c.GarmentA = new MasterGarment(); c.GarmentA.EventCode = 3; c.GarmentA.SeasonCode = 15; po.Accesory1 = new MasterGarment(); po.Accesory1.EventCode = 3; po.Accesory1.SeasonCode = 3; c.GarmentB = new MasterGarment(); c.GarmentB.EventCode = 1; c.GarmentB.SeasonCode = 3; po.Combination = c; OutfitValidationService.VerifyAndSetSeasonsAndEventTypes(seasons, eventTypes, po); Assert.IsTrue(seasons.Sum() == 3, seasons.Sum().ToString()); Assert.IsTrue(eventTypes.Sum() == 1, eventTypes.Sum().ToString()); }
private void IncludeAccesories(IEnumerable <PreCombination> currentCombinations, IEnumerable <PreCombination> accesories, int amount) { foreach (PreCombination comb in currentCombinations) { // Make sure there will be only 10 garments per outfit. int combinationAmount = 2; if (comb.GarmentC != null) { combinationAmount++; } if (comb.GarmentD != null) { combinationAmount++; } if (comb.GarmentE != null) { combinationAmount++; } if (combinationAmount + amount > 10) { continue; } foreach (PreCombination acc in accesories) { PreOutfit outfit = new PreOutfit(); outfit.Combination = comb; outfit.Accesory1 = acc.GarmentA; outfit.Accesory2 = acc.GarmentB; outfit.Accesory3 = acc.GarmentC; outfit.Accesory4 = acc.GarmentD; outfit.Accesory5 = acc.GarmentE; outfits.Add(outfit); } } }
public static bool IsValidOutfit(PreOutfit outfit, StyleRule sr, HashSet <int> seasons, HashSet <int> eventTypes) { Combination comb = outfit.Combination; if (!OutfitValidationService.VerifyAndSetSeasonsAndEventTypes(seasons, eventTypes, outfit)) { return(false); } HashSet <ColorFamily> colorFamiliesHash = new HashSet <ColorFamily>(); if (comb.GarmentA != null) { colorFamiliesHash.Add(comb.GarmentA.Tags.Colors[0].Family); } if (comb.GarmentB != null) { colorFamiliesHash.Add(comb.GarmentB.Tags.Colors[0].Family); } if (comb.GarmentC != null) { colorFamiliesHash.Add(comb.GarmentC.Tags.Colors[0].Family); } if (comb.GarmentD != null) { colorFamiliesHash.Add(comb.GarmentD.Tags.Colors[0].Family); } if (comb.GarmentE != null) { colorFamiliesHash.Add(comb.GarmentE.Tags.Colors[0].Family); } if (outfit.Accesory1 != null && !IsJewleryColor(outfit.Accesory1)) { colorFamiliesHash.Add(outfit.Accesory1.Tags.Colors[0].Family); } if (outfit.Accesory2 != null && !IsJewleryColor(outfit.Accesory2)) { colorFamiliesHash.Add(outfit.Accesory2.Tags.Colors[0].Family); } if (outfit.Accesory3 != null && !IsJewleryColor(outfit.Accesory3)) { colorFamiliesHash.Add(outfit.Accesory3.Tags.Colors[0].Family); } if (outfit.Accesory4 != null && !IsJewleryColor(outfit.Accesory4)) { colorFamiliesHash.Add(outfit.Accesory4.Tags.Colors[0].Family); } if (outfit.Accesory5 != null && !IsJewleryColor(outfit.Accesory5)) { colorFamiliesHash.Add(outfit.Accesory5.Tags.Colors[0].Family); } if (outfit.Accesory6 != null && !IsJewleryColor(outfit.Accesory6)) { colorFamiliesHash.Add(outfit.Accesory6.Tags.Colors[0].Family); } if (outfit.Accesory7 != null && !IsJewleryColor(outfit.Accesory7)) { colorFamiliesHash.Add(outfit.Accesory7.Tags.Colors[0].Family); } if (outfit.Accesory8 != null && !IsJewleryColor(outfit.Accesory8)) { colorFamiliesHash.Add(outfit.Accesory8.Tags.Colors[0].Family); } if (!OutfitValidationService.IsValidCombination(colorFamiliesHash, null, null, null, sr, null, false, true)) { return(false); } if (seasons.Contains((int)Season.Summer)) { bool hasD = false; if ( (comb.GarmentA != null && comb.GarmentA.Tags.Silouhette.Layers.Contains(LayerCode.D)) || (comb.GarmentB != null && comb.GarmentB.Tags.Silouhette.Layers.Contains(LayerCode.D)) || (comb.GarmentC != null && comb.GarmentC.Tags.Silouhette.Layers.Contains(LayerCode.D)) || (comb.GarmentD != null && comb.GarmentD.Tags.Silouhette.Layers.Contains(LayerCode.D)) || (comb.GarmentE != null && comb.GarmentE.Tags.Silouhette.Layers.Contains(LayerCode.D)) ) { hasD = true; } bool hasB = false; if ( (comb.GarmentA != null && comb.GarmentA.Tags.Silouhette.Layers.Contains(LayerCode.B)) || (comb.GarmentB != null && comb.GarmentB.Tags.Silouhette.Layers.Contains(LayerCode.B)) || (comb.GarmentC != null && comb.GarmentC.Tags.Silouhette.Layers.Contains(LayerCode.B)) || (comb.GarmentD != null && comb.GarmentD.Tags.Silouhette.Layers.Contains(LayerCode.B)) || (comb.GarmentE != null && comb.GarmentE.Tags.Silouhette.Layers.Contains(LayerCode.B)) ) { hasB = true; } bool hasC = false; if ( (comb.GarmentA != null && comb.GarmentA.Tags.Silouhette.Layers.Contains(LayerCode.C)) || (comb.GarmentB != null && comb.GarmentB.Tags.Silouhette.Layers.Contains(LayerCode.C)) || (comb.GarmentC != null && comb.GarmentC.Tags.Silouhette.Layers.Contains(LayerCode.C)) || (comb.GarmentD != null && comb.GarmentD.Tags.Silouhette.Layers.Contains(LayerCode.C)) || (comb.GarmentE != null && comb.GarmentE.Tags.Silouhette.Layers.Contains(LayerCode.C)) ) { hasC = true; } if (hasD || (hasB && hasC)) { seasons.Remove((int)Season.Summer); } } return(true); }
public static bool VerifyAndSetSeasonsAndEventTypes(HashSet <int> seasons, HashSet <int> eventTypes, PreOutfit of) { // Load first data available seasons.Clear(); seasons.Add(of.Combination.GarmentA.SeasonCode & (int)Season.Fall); seasons.Add(of.Combination.GarmentA.SeasonCode & (int)Season.Spring); seasons.Add(of.Combination.GarmentA.SeasonCode & (int)Season.Summer); seasons.Add(of.Combination.GarmentA.SeasonCode & (int)Season.Winter); seasons.Remove(0); eventTypes.Clear(); eventTypes.Add(of.Combination.GarmentA.EventCode & 1); eventTypes.Add(of.Combination.GarmentA.EventCode & 2); eventTypes.Add(of.Combination.GarmentA.EventCode & 4); eventTypes.Add(of.Combination.GarmentA.EventCode & 8); eventTypes.Add(of.Combination.GarmentA.EventCode & 16); eventTypes.Remove(0); seasons.Intersect(GetSeasons(of.Combination.GarmentB)); seasons.Intersect(GetSeasons(of.Combination.GarmentC)); seasons.Intersect(GetSeasons(of.Combination.GarmentD)); seasons.Intersect(GetSeasons(of.Combination.GarmentE)); seasons.Intersect(GetSeasons(of.Accesory1)); seasons.Intersect(GetSeasons(of.Accesory2)); seasons.Intersect(GetSeasons(of.Accesory3)); seasons.Intersect(GetSeasons(of.Accesory4)); seasons.Intersect(GetSeasons(of.Accesory5)); seasons.Intersect(GetSeasons(of.Accesory6)); seasons.Intersect(GetSeasons(of.Accesory7)); seasons.Intersect(GetSeasons(of.Accesory8)); eventTypes.Intersect(GetEventTypes(of.Combination.GarmentB)); eventTypes.Intersect(GetEventTypes(of.Combination.GarmentC)); eventTypes.Intersect(GetEventTypes(of.Combination.GarmentD)); eventTypes.Intersect(GetEventTypes(of.Combination.GarmentE)); eventTypes.Intersect(GetEventTypes(of.Accesory1)); eventTypes.Intersect(GetEventTypes(of.Accesory2)); eventTypes.Intersect(GetEventTypes(of.Accesory3)); eventTypes.Intersect(GetEventTypes(of.Accesory4)); eventTypes.Intersect(GetEventTypes(of.Accesory5)); eventTypes.Intersect(GetEventTypes(of.Accesory6)); eventTypes.Intersect(GetEventTypes(of.Accesory7)); eventTypes.Intersect(GetEventTypes(of.Accesory8)); return(eventTypes.Count > 0 && seasons.Count > 0); }
private void IncludeAccesories(IEnumerable <Combination> currentCombinations, IEnumerable <Combination> accesories, int amount) { var seasons = new HashSet <int>(); var eventTypes = new HashSet <int>(); foreach (Combination comb in currentCombinations) { // Make sure there will be only 10 garments per outfit. int combinationAmount = 2; if (comb.GarmentC != null) { combinationAmount++; } if (comb.GarmentD != null) { combinationAmount++; } if (comb.GarmentE != null) { combinationAmount++; } if (combinationAmount + amount > 10) { continue; } int i = 0; foreach (Combination acc in accesories) { // Exclude combination if does not contains an added garment. if (newGarments != null) { if (!newGarments.Contains(comb.GarmentA) && !newGarments.Contains(comb.GarmentB) && !newGarments.Contains(comb.GarmentC) && !newGarments.Contains(comb.GarmentD) && !newGarments.Contains(comb.GarmentE) && !newGarments.Contains(acc.GarmentA) && !newGarments.Contains(acc.GarmentB) && !newGarments.Contains(acc.GarmentC) && !newGarments.Contains(acc.GarmentD) && !newGarments.Contains(acc.GarmentE) && !newGarments.Contains(acc.GarmentF) && !newGarments.Contains(acc.GarmentG) && !newGarments.Contains(acc.GarmentH) ) { continue; } } var outfit = new PreOutfit(); outfit.Combination = comb; outfit.Accesory1 = acc.GarmentA; outfit.Accesory2 = acc.GarmentB; outfit.Accesory3 = acc.GarmentC; outfit.Accesory4 = acc.GarmentD; outfit.Accesory5 = acc.GarmentE; outfit.Accesory6 = acc.GarmentF; outfit.Accesory7 = acc.GarmentG; outfit.Accesory8 = acc.GarmentH; if (!OutfitValidationService.IsValidOutfit(outfit, currentStyleRule, seasons, eventTypes)) { continue; } outfit.Seasons = seasons.Sum(); outfit.EventTypes = eventTypes.Sum(); outfits.Add(outfit); seasons.Clear(); eventTypes.Clear(); // Limit to 20 accesories per combination maximum. if (i >= MAX_ACCESORIES_PER_COMBINATION) { break; } i++; } } }