5
5
<div class =" card" >
6
6
<div class =" card-header" >Blog Post Visit Counts</div >
7
7
<div class =" card-body" >
8
- <table class =" table table-striped" >
8
+ <table class =" table table-striped table-hover " >
9
9
<tbody >
10
10
<tr >
11
11
<th >Title</th >
12
12
<th >Clicks</th >
13
+ <th >Likes</th >
13
14
</tr >
14
15
@if (PageVisitCount != null )
15
16
{
16
- @foreach ( var pageVisit in blogPostToCountList )
17
+ @foreach ( var ( blogPost , visitCount ) in blogPostToCountList )
17
18
{
18
19
<tr >
19
- <td >@pageVisit.Key </td >
20
- <td >@pageVisit.Value </td >
20
+ <td ><a href =" blogPost/@blogPost.Id" >@blogPost.Title </a ></td >
21
+ <td >@visitCount </td >
22
+ <td >@blogPost.Likes </td >
21
23
</tr >
22
24
}
23
25
}
30
32
[Parameter ]
31
33
public IOrderedEnumerable <KeyValuePair <string, int >> PageVisitCount { get ; set ; }
32
34
33
- private List <KeyValuePair <string , int >> blogPostToCountList = new ();
35
+ private List <KeyValuePair <BlogPost , int >> blogPostToCountList = new ();
34
36
35
37
protected override async Task OnParametersSetAsync ()
36
38
{
39
41
return ;
40
42
}
41
43
42
- foreach (var (blogPost , clickCount ) in PageVisitCount )
44
+ foreach (var (blogPostUrl , clickCount ) in PageVisitCount )
43
45
{
44
- var blogPostId = blogPost [( blogPost .IndexOf ('/' ) + 1 ).. ];
46
+ var blogPostId = blogPostUrl [( blogPostUrl .IndexOf ('/' ) + 1 ).. ];
45
47
46
48
if (string .IsNullOrEmpty (blogPostId ))
47
49
{
48
50
continue ;
49
51
}
50
52
51
- var blogPostTitle = (await blogPostRepository .GetByIdAsync (blogPostId )). Title ;
53
+ var blogPost = (await blogPostRepository .GetByIdAsync (blogPostId ));
52
54
53
- blogPostToCountList .Add (new KeyValuePair <string , int >(blogPostTitle , clickCount ));
55
+ blogPostToCountList .Add (new KeyValuePair <BlogPost , int >(blogPost , clickCount ));
54
56
}
55
57
}
56
58
}
0 commit comments