Пример #1
0
        public List <string> GetUserSuggestion(string username, int suggestionToTake = 3)
        {
            List <string> filteredSuggestion = new List <string>();
            Random        _rdm = new Random();

GOTO_RetrySuggestions:
            //Generate User Suggestions
            List <String> userSuggestions = new List <string>();

            userSuggestions.Add(username + _rdm.Next(1000, 9999));
            userSuggestions.Add(username + _rdm.Next(1000, 9999));
            userSuggestions.Add(username + _rdm.Next(1000, 9999));
            userSuggestions.Add(username + _rdm.Next(1000, 9999));
            userSuggestions.Add(username + _rdm.Next(1000, 9999));

            //Check All of these in DB
            filteredSuggestion.AddRange(applicationUserRepository.CheckUserSuggestion(userSuggestions));

            //If atleast 3 suggestion are filtered/found, then return
            //otherwise retry and find suggestions
            if (filteredSuggestion.Count < 3)
            {
                goto GOTO_RetrySuggestions;
            }

            return(filteredSuggestion.Take(suggestionToTake).ToList());
        }