Beispiel #1
0
        public IEnumerable <SuggestionModel> GetSuggestions()
        {
            var userId = UserId;

            var suggestions = new List <SuggestionModel>();

            _suggestionService.GetSuggestions().ForEach(p => suggestions.Add(new SuggestionModel()
            {
                Id          = p.Id,
                Description = p.Description,
                Date        = p.Date,
                UpVote      = p.UpVotes,
                DownVote    = p.DownVotes,
                Archived    = (p.Archived != null && p.Archived == true),
                HasVoted    = p.SuggestionVotes.Any(v => v.UserId == userId)
            }));

            return(suggestions);
        }
Beispiel #2
0
        public void SuggestionServiceReturnsCorrectSuggestions()
        {
            // Arrange
            var expectedValues = _dict.Values.SelectMany(w => w.Links)
                                 .Select(w => w.Text)
                                 .Union(_dict.Keys)
                                 .Distinct()
                                 .ToList();
            // Act
            var actualValues = _suggestionService.GetSuggestions();

            // Assert
            CollectionAssert.AreEqual(expectedValues, actualValues);
        }
Beispiel #3
0
        public async Task <JsonResult> Get(string q = null, string longitude = null, string latitude = null)
        {
            var suggestions = new Suggestions();

            if (!String.IsNullOrEmpty(q))
            {
                // create our DTO to send to the repository
                Search searchDTO = CreateSearchDTO(q, longitude, latitude);

                // call the repository
                suggestions = await _service.GetSuggestions(searchDTO);
            }
            else
            {
                suggestions.ListSuggestion = new List <Suggestions.Suggestion>();
            }

            return(Json(suggestions));
        }
Beispiel #4
0
        private async Task LoadSuggestions()
        {
            var result = await _suggestionService.GetSuggestions();

            Suggestions.AddRange(result);
        }