public List <FastFoods> Search(FastFoodsInputCommand command)
        {
            Query q = new Query($"(@name:{ command.Sentence })*|(@address:{ command.Sentence }*)|(@country:BR*)")
                      .SetLanguage("portuguese");

            //todo: insert this validation in model
            //check if exists lat, lon and radius
            if (!Equals(0, command.Latitude) && !Equals(0, command.Longitude) && !Equals(0, command.Kilometers))
            {
                q.AddFilter(new Query.GeoFilter("GeoPoint", command.Longitude, command.Latitude, command.Kilometers, StackExchange.Redis.GeoUnit.Kilometers));
            }

            var result = _client.Search(q).Documents;

            return(CastRedisValues <FastFoods>(result));
        }
        public async Task <IEnumerable <FastFoods> > SearchAsync(FastFoodsInputCommand command)
        {
            Query q = new Query($"(@Name:{ command.Sentence }*)|(@Address:{ command.Sentence }*)")
                      .SetLanguage("portuguese");

            //todo: insert this validation in model
            //check if exists lat, lon and radius
            if (!Equals(0, command.Latitude) && !Equals(0, command.Longitude) && !Equals(0, command.Kilometers))
            {
                q.AddFilter(new Query.GeoFilter("GeoPoint", command.Longitude, command.Latitude, command.Kilometers, StackExchange.Redis.GeoUnit.Kilometers));
            }

            var result = await _client.SearchAsync(q);

            var stringResponse = result.Documents;

            return(CastRedisValues <FastFoods>(stringResponse));
        }
 public async Task <ActionResult <IEnumerable <FastFoods> > > Search([FromQuery] FastFoodsInputCommand command)
 {
     try
     {
         return(Ok(new Notification
         {
             Success = true,
             Data = await _fastFoodService.SearchAsync(command)
         }));
     }
     catch (Exception ex)
     {
         return(BadRequest(new Notification
         {
             Success = false,
             Errors = ex.Message
         }));
     }
 }
예제 #4
0
 public Task <IEnumerable <FastFoods> > SearchAsync(FastFoodsInputCommand command)
 {
     command.Sentence = command.Sentence.Trim();
     return(_fastFoodsRepository.SearchAsync(command));
 }