using Microsoft.AspNetCore.Mvc;
using RestaurantAPI.Models;
using System.Collections.Generic;
using System.Threading.Tasks;
[Route("api/restaurants")]
[ApiController]
public class RestaurantController : ControllerBase
{
private readonly GooglePlacesService _googlePlacesService;
// Inject GooglePlacesService into the controller
public RestaurantController(GooglePlacesService googlePlacesService)
{
_googlePlacesService = googlePlacesService;
}
///
/// Fetches restaurants from Google Places API based on location.
///
/// Latitude of the location (default: Brickell, Miami)
/// Longitude of the location (default: Brickell, Miamik)
/// Search radius in meters (default: 5000m)
/// List of restaurants from Google Places API
[HttpGet]
public async Task>> GetRestaurants(
[FromQuery] double latitude = 25.7617,
[FromQuery] double longitude = -80.1918,
[FromQuery] int radius = 5000)
{
var restaurants = await _googlePlacesService.GetRestaurantsAsync(latitude, longitude, radius);
return Ok(restaurants);
}
}