You are on page 1of 1

Chapter 7 Practice Tasks for 

Server-side

Main.razor. Going further with the variables, you can notice four lists
created, each with their own type of object. Also, you can see that we
only have one list for score, even though a score has three types. The
types of score are declared as value in the record. To display the current
results, for the most part, we simply bind Count property of the Lists
with the exception of score. For the score, we are displaying total;
therefore, we need to calculate that. To make it simple, we just run a loop
in the page, which gets re-run every time the count property changes.
Finally, we have a few methods that will simply add new item on click.

Listing 7-14.  Index page

@page "/"

<div style="width:50%;float:left;">
    <TeamComponenent team="1" gameid="@gameid">
</TeamComponenent>
</div>

<div style="width:50%;float:left;">
    <TeamComponenent team="2" gameid="@gameid" >
</TeamComponenent>
</div>

@code {
Guid gameid;

protected override Task OnInitializedAsync() {


    gameid = Guid.NewGuid();
    return base.OnInitializedAsync();
}

149

You might also like