Beispiel #1
0
        public IActionResult Index(string patternInput)
        {
            var patterns = _nineLetterService.GetPatternResult().Result.ToList();

            if (string.IsNullOrEmpty(patternInput) || patternInput.Length != 9)
            {
                var pattern = patterns.FirstOrDefault(x => x.Words.Any());

                if (pattern != null)
                {
                    return(View("Index", new BasePage
                    {
                        Result = new Result
                        {
                            Patterns = patterns,
                            Pattern = pattern.Pattern,
                            PossibleWords = pattern.PossibleWords,
                            Words = pattern.Words,
                            LongestWord = pattern.Words.Last()
                        }
                    }));
                }
            }

            var patternInputResult = patterns.FirstOrDefault(x => x.Pattern.Equals(patternInput, StringComparison.CurrentCultureIgnoreCase));

            if (patternInputResult != null)
            {
                return(View("Index", new BasePage
                {
                    Result = new Result
                    {
                        Patterns = patterns,
                        Pattern = patternInputResult.Pattern,
                        PossibleWords = patternInputResult.PossibleWords,
                        Words = patternInputResult.Words,
                        LongestWord = patternInputResult.Words.Last()
                    }
                }));
            }

            return(View("Index", new BasePage
            {
                Result = new Result
                {
                    Patterns = patterns,
                    Pattern = patternInput,
                }
            }));
        }
Beispiel #2
0
 public async Task <IEnumerable <Result> > PatternList()
 {
     return(await _nineLetterService.GetPatternResult());
 }