public LusherTestResultModel ProcessData(List <List <int> > colorSet, int userId) { var domainModel = new LusherTest { FirstChoice = colorSet.First().Select(item => new LusherChoice { Color = item }).ToList(), SecondChoice = colorSet.Skip(1).First().Select(item => new LusherChoice { Color = item }).ToList() }; var result = _processor.ProcessData(domainModel); var testId = SaveTestData(result, userId); return(GetLusherTestResultById(testId, userId)); }
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); }
public LusherTestResult ProcessData(LusherTest test) { ColorComparison(test.FirstChoice, test.SecondChoice); return(ResultsPreparation(test)); }