@page "/MovieReview/{Id}"
@attribute [StreamRendering(true)]
@inject IMovieReviewService MovieReviewService

@if(MovieItem == null)
{
    <h3>Loading...</h3>
}
else
{
    <h1>@MovieItem?.Title</h1>
    <div class="row">
        <div class="col-6">
            <img style="width: 100%" src="@MovieItem?.ImageUrl" alt="@MovieItem?.Title"/>
        </div>
        <div class="col-6">
            @MovieItem?.Review
        </div>
    </div>
}


@code {

    [Parameter]
    public string Id { get; set; }

    private MovieModel? MovieItem { get; set; }

    protected override async Task OnInitializedAsync()
    {
        await Task.Delay(1000);

        if (Id != null)
        {
            int? id = int.Parse(Id);
            MovieItem = await MovieReviewService.GetMovieById(id.Value);
        }

    }
}
