Ejemplo n.º 1
0
        public void AddNewLogDeleted(string ip, DateTime time, string cachedWord)
        {
            int?cachedWordID = cachedWordsService.GetCachedWordID(cachedWord);

            if (cachedWordID == null)
            {
                cachedWordsService.FindAnagrams(cachedWord);
                cachedWordID = cachedWordsService.GetCachedWordID(cachedWord);
            }
            UserLogFull userLog = new UserLogFull(ip, time, cachedWordID.Value, "Delete");

            Repository.AddUserLog(userLog);
        }
Ejemplo n.º 2
0
        public async Task Anagram_IsPermitted_GetCorrectAnagrams()
        {
            _userLogService.IsPermittedToView(Arg.Any <string>()).Returns(true);
            _cachedWordsService.FindAnagrams("alus").Returns(new List <string> {
                "sula", "alus"
            });

            ViewResult result = await _homeController.Anagram("alus");

            result.ViewData.Values.ShouldBe(new List <List <string> > {
                new List <string> {
                    "sula", "alus"
                }
            });
        }
Ejemplo n.º 3
0
        //find word anagrams
        public async Task <ViewResult> Anagram(String word)
        {
            string ip = LogActivities.GetIPAddress();

            if (UsersLogService.IsPermittedToView(ip))
            {
                //cookies - last searched words
                WebCookies.AddNewWordToHistory(Request, Response, word);
                //find anagrams -- find if there are cached words
                //List<string> anagrams = CachedWordService.FindAnagrams(word);
                List <string> anagrams = await Task.Run(() => (CachedWordService.FindAnagrams(word)));

                ViewBag.Anagrams = anagrams;
                //UserLog
                Task.Run(() => LogActivities.LogWordViewed(word));
            }
            else
            {
                ViewBag.Permitted = false;
            }
            return(View("Index"));
        }