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); }
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); }
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)); }
private async Task LoadSuggestions() { var result = await _suggestionService.GetSuggestions(); Suggestions.AddRange(result); }