public UnscrambleGameResultViewModel(UnscrambledSentence that, string answer) { this.Id = that.Id; this.CorrectSentence = that.Sentence; this.AnsweredSentence = answer; this.CorrectlyAnsweredWords = new List<string>(); this.WronglyAnsweredWords = new List<string>(); var correctWords = that.Sentence.Split(' '); var answeredWords = answer.Split(' '); for(int i = 0; i < answeredWords.Count(); i++) { if (i >= correctWords.Count() || answeredWords[i] != correctWords[i]) { WronglyAnsweredWords.Add(answeredWords[i]); } else { CorrectlyAnsweredWords.Add(answeredWords[i]); } } }
public UnscrambleGameViewmodel(UnscrambledSentence that) { this.Id = that.Id; this.AnsweredSentence = null; var scramble = that.Sentence.Split(' '); Random random = new Random(); this.ScrambledSentence = string.Join(" ",scramble.OrderBy((item) => random.Next()).ToList()); }