Exemplo n.º 1
0
        public SuggestResult Suggest(string text)
        {
            var suggestResponse = client.Suggest <RoomDocument>(suggest => suggest.GlobalText(text).Index(indexName)
                                                                .Completion("Rooms", descriptor => descriptor.Field(r => r.RoomNameCompletion))
                                                                .Completion("Hotels", descriptor => descriptor.Field(r => r.HotelNameCompletion))
                                                                );

            return(new SuggestResult {
                Suggestions = suggestResponse.Suggestions.Select(s => SuggestionDTO.FromSuggestion(s)).Where(s => s.Terms.Any())
            });
        }
Exemplo n.º 2
0
        public ActionResult <Suggestion> PostSuggestion(SuggestionDTO suggestion)
        {
            Console.WriteLine("post method called");
            Console.WriteLine(suggestion.ToString());
            Suggestion suggestionToCreate = new Suggestion()
            {
                Name        = suggestion.Name,
                Longtitude  = suggestion.Longtitude,
                Latitude    = suggestion.Latitude,
                Description = suggestion.Description
            };

            _suggestions.Add(suggestionToCreate);
            _suggestions.SaveChanges();

            return(CreatedAtAction(nameof(GetSuggestion), new { id = suggestionToCreate.Id }, suggestionToCreate));
        }
Exemplo n.º 3
0
        public void LoadData(string strSuggestionHaveFile, string strSuggestionNotHaveFile)
        {
            StreamReader reader = null;

            _sugHaves    = new List <SuggestionDTO>();
            _sugNotHaves = new List <SuggestionDTO>();

            try
            {
                reader = new StreamReader(strSuggestionHaveFile);
                for (int i = 0; i < 10; i++)
                {
                    reader.ReadLine();
                    SuggestionDTO sug = new SuggestionDTO();
                    sug.Up      = reader.ReadLine().Trim();
                    sug.Sideway = reader.ReadLine().Trim();
                    sug.Down    = reader.ReadLine().Trim();
                    _sugHaves.Add(sug);
                }
                reader.Close();
                reader.Dispose();

                reader = new StreamReader(strSuggestionNotHaveFile);
                for (int i = 0; i < 10; i++)
                {
                    reader.ReadLine();
                    SuggestionDTO sug = new SuggestionDTO();
                    sug.Up      = reader.ReadLine().Trim();
                    sug.Sideway = reader.ReadLine().Trim();
                    sug.Down    = reader.ReadLine().Trim();
                    _sugNotHaves.Add(sug);
                }
                reader.Close();
                reader.Dispose();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public SuggestResult Suggest(string text)
        {
#if false //todo
            var suggestResponse = client.Suggest <RoomDocument>(suggest => suggest.GlobalText(text).Index(indexName)
                                                                .Completion("Rooms", descriptor => descriptor.Field(r => r.RoomNameCompletion))
                                                                .Completion("Hotels", descriptor => descriptor.Field(r => r.HotelNameCompletion))
                                                                );
            return(new SuggestResult {
                Suggestions = suggestResponse.Suggestions.Select(s => SuggestionDTO.FromSuggestion(s)).Where(s => s.Terms.Any())
            });
#else
            return(new SuggestResult {
                Suggestions = new List <SuggestionDTO> {
                    new SuggestionDTO {
                        Suggestion = "serge", Terms = new List <string> {
                            "dean", "scott", "tahne"
                        }
                    }
                }
            });
#endif
        }