Example #1
0
        private int GetInterpretationKey(LusherResultGroup result)
        {
            var key = result.SecondAnxiety ? "a" : "";

            key += $"{result.SecondGroup.ToAbbreviation()}{result.SecondColor}{result.SecondGroup.ToAbbreviation()}{result.FirstColor}";
            var entity = _interpretationRepository.GetInterpretationByKey(key);

            return(entity?.LusherInterpretationId ?? _interpretationRepository.GetDefaultEntity().LusherInterpretationId);
        }
        private static LusherTestResult ResultsPreparation(LusherTest test)
        {
            var result = new LusherTestResult()
            {
                Intensity = test.FirstChoice.Sum(item => item.Intensity) + test.SecondChoice.Sum(item => item.Intensity),
                ColorSet  = new List <List <LusherChoice> >
                {
                    test.FirstChoice,
                    test.SecondChoice
                },
                Groups = new List <LusherResultGroup>()
            };

            var groups = new List <LusherResultGroup>();

            for (var i = 0; i < test.FirstChoice.Count; i++)
            {
                groups.Add(new LusherResultGroup
                {
                    FirstColor    = test.FirstChoice[i].Color,
                    SecondAnxiety = test.SecondChoice[i].Anxiety,
                    SecondGroup   = test.SecondChoice[i].Group,
                    SecondColor   = test.SecondChoice[i].Color,
                    Position      = i
                });
            }

            LusherResultGroup previousLusherResultGroup = null;

            foreach (var lusherResultGroup in groups)
            {
                if (!(previousLusherResultGroup != null &&
                      lusherResultGroup.FirstColor == previousLusherResultGroup.SecondColor &&
                      lusherResultGroup.SecondColor == previousLusherResultGroup.FirstColor))
                {
                    result.Groups.Add(lusherResultGroup);
                }

                previousLusherResultGroup = lusherResultGroup;
            }

            return(result);
        }