public async Task <Object> GetResponseFromServiceWithQuery(GetResponseFromServiceWithQueryDto model)
        {
            string timeFormatForUrl = DateTime.Now.ToString("yyyyMMdd");

            LocationEntity location = new LocationEntity();

            location.latitude  = model.latitude;
            location.longitude = model.longitude;

            var loc = new LocationDTO();

            loc.latitude  = model.latitude;
            loc.longitude = model.longitude;

            await _context.Locations.AddAsync(location);

            await _context.SaveChangesAsync();

            await _hubContext.Clients.All.SendAsync("OnLocation", loc);

            HttpClient httpClient    = new HttpClient();
            string     rawStringJSON = await httpClient.GetStringAsync($"{_myConfig.foursquare} { model.latitude.Value.ToString(CultureInfo.InvariantCulture)},{ model.longitude.Value.ToString(CultureInfo.InvariantCulture)}&v={ timeFormatForUrl}&limit=10&name={ model.categoryQuery}");

            Object deserializedJSON = JsonConvert.DeserializeObject(rawStringJSON);

            return(deserializedJSON);
        }
Example #2
0
        public async Task <ActionResult <LocationEntity> > GetResponseFromServiceWithQuery([FromBody] GetResponseFromServiceWithQueryDto model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var result = await _locationService.GetResponseFromServiceWithQuery(model);

            return(Ok(result));
        }