public ActionResult <SearchWord> GetSearchWords([FromBody] IdForWords[] id)
        {
            List <int> listIds = new List <int>();

            for (int i = 0; i < id.Length; i++)
            {
                listIds.Add(id[i].Id);
            }
            int[] arrayIds = listIds.ToArray();
            var   words    = _dataService.GetWords(arrayIds);

            if (words == null)
            {
                return(NotFound());
            }

            List <ReturnWord> returnList = new List <ReturnWord>();

            for (int j = 0; j < words.Count; j++)
            {
                ReturnWord tempword = new ReturnWord()
                {
                    Text = words[j].Word, Weight = words[j].Weight
                };
                returnList.Add(tempword);
            }

            return(Ok(returnList.ToArray()));
        }
Example #2
0
        public void getWordsForWordCloud()
        {
            var service = new DataService();

            int[] postArray   = new[] { 19 };
            var   returnWords = service.GetWords(postArray);

            List <ReturnWord> returnList = new List <ReturnWord>();

            for (int j = 0; j < returnWords.Count; j++)
            {
                ReturnWord tempword = new ReturnWord()
                {
                    Text = returnWords[j].Word, Weight = returnWords[j].Weight
                };
                returnList.Add(tempword);
            }
            ReturnWord tmp = new ReturnWord()
            {
                Text = "''", Weight = 1
            };

            Assert.Equal(tmp.Text, returnList.First().Text);
            Assert.Equal(tmp.Weight, returnList.First().Weight);
        }