using CityInfo.WEB.Models;
using CityInfo.WEB.Services;
using Microsoft.AspNetCore.Components;

namespace CityInfo.WEB.Pages
{
    public partial class PointOfInterestDetails
    {
        [Inject]
        public IPointOfInterestDataService PointOfInterestDataService { get; set; } = default!;
        [Inject]
        public ICityDataService CityDataService { get; set; } = default!;
        [Inject]
        public NavigationManager NavigationManager { get; set; } = default!;
        [Parameter]
        public int CityId { get; set; }
        [Parameter]
        public int PointOfInterestId { get; set; }
        public PointOfInterest? PointOfInterest { get; set; }
        public City? City { get; set; }

        protected async override Task OnInitializedAsync()
        {
            PointOfInterest = await PointOfInterestDataService.GetPointOfInterest(CityId, PointOfInterestId);
            if (PointOfInterest == null)
            {
                NavigationManager.NavigateTo("not-found");
                return;
            }
            City = await CityDataService.GetCity(CityId);
        }
    }
}
