File tree Expand file tree Collapse file tree 2 files changed +31
-5
lines changed
LinkDotNet.Blog.Web/Pages Expand file tree Collapse file tree 2 files changed +31
-5
lines changed Original file line number Diff line number Diff line change 2
2
@using LinkDotNet .Infrastructure .Persistence
3
3
@using LinkDotNet .Domain
4
4
@attribute [Authorize]
5
- @inject IRepository _repository
5
+ @inject IRepository repository
6
6
<h3 >Draft Blog Posts</h3 >
7
7
8
8
<div class =" content px-4" >
9
- @for ( var i = 0 ; i < _blogPosts .Count ; i ++ )
9
+ @for ( var i = 0 ; i < blogPosts .Count ; i ++ )
10
10
{
11
- <ShortBlogPost BlogPost =" _blogPosts [i]" UseAlternativeStyle =" @(i % 2 != 0)" ></ShortBlogPost >
11
+ <ShortBlogPost BlogPost =" blogPosts [i]" UseAlternativeStyle =" @(i % 2 != 0)" ></ShortBlogPost >
12
12
}
13
13
</div >
14
14
15
15
@code {
16
- private IList <BlogPost > _blogPosts = new List <BlogPost >();
16
+ private IList <BlogPost > blogPosts = new List <BlogPost >();
17
17
18
18
protected override async Task OnInitializedAsync ()
19
19
{
20
- _blogPosts = (await _repository .GetAllAsync (p => ! p .IsPublished , b => b .UpdatedDate )).ToList ();
20
+ blogPosts = (await repository .GetAllAsync (p => ! p .IsPublished , b => b .UpdatedDate )).ToList ();
21
21
}
22
22
23
23
}
Original file line number Diff line number Diff line change
1
+ @page " /search/{searchTerm}"
2
+ @using LinkDotNet .Infrastructure .Persistence
3
+ @using LinkDotNet .Domain
4
+ @inject IRepository repository
5
+ <h3 >Results for @SearchTerm </h3 >
6
+
7
+ <div class =" content px-4" >
8
+ @for ( var i = 0 ; i < blogPosts .Count ; i ++ )
9
+ {
10
+ <ShortBlogPost BlogPost =" blogPosts[i]" UseAlternativeStyle =" @(i % 2 != 0)" ></ShortBlogPost >
11
+ }
12
+ </div >
13
+
14
+ @code {
15
+ [Parameter ]
16
+ public string SearchTerm { get ; set ; }
17
+
18
+ private IList <BlogPost > blogPosts = new List <BlogPost >();
19
+
20
+ protected override async Task OnInitializedAsync ()
21
+ {
22
+ blogPosts = (await repository .GetAllAsync (t => t .IsPublished && (t .Title .Contains (SearchTerm )
23
+ || t .Tags .Any (tag => tag .Content == SearchTerm )),
24
+ b => b .UpdatedDate )).ToList ();
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments