33 lines
1.0 KiB
C#
33 lines
1.0 KiB
C#
using CityInfo.WEB.Models;
|
|
using CityInfo.WEB.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace CityInfo.WEB.Pages
|
|
{
|
|
public partial class CityDetails
|
|
{
|
|
[Inject]
|
|
public ICityDataService CityDataService { get; set; } = default!;
|
|
[Inject]
|
|
public IPointOfInterestDataService PointOfInterestDataService { get; set; }
|
|
[Inject]
|
|
public NavigationManager NavigationManager { get; set; } = default!;
|
|
[Parameter]
|
|
public int CityId { get; set; }
|
|
public City? City { get; set; }
|
|
public IEnumerable<PointOfInterest> PointsOfInterest { get; set; } = new List<PointOfInterest>();
|
|
|
|
protected async override Task OnInitializedAsync()
|
|
{
|
|
City = await CityDataService.GetCity(CityId);
|
|
if(City == null)
|
|
{
|
|
NavigationManager.NavigateTo("/not-found");
|
|
return;
|
|
}
|
|
PointsOfInterest = await PointOfInterestDataService.GetPointsOfInterest(CityId);
|
|
}
|
|
|
|
}
|
|
}
|