Skip to content

Commit 4d760f4

Browse files
committed
Added possibility to specify the page size
1 parent 65b9246 commit 4d760f4

File tree

8 files changed

+15
-5
lines changed

8 files changed

+15
-5
lines changed

LinkDotNet.Blog.IntegrationTests/Web/Pages/IndexTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ private static AppConfiguration CreateSampleAppConfiguration()
120120
BackgroundUrl = string.Empty,
121121
ProfilePictureUrl = string.Empty,
122122
},
123+
BlogPostsPerPage = 10,
123124
};
124125
}
125126

LinkDotNet.Blog.UnitTests/Web/AppConfigurationFactoryTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public void ShouldMapFromAppConfiguration()
2121
{ "Introduction:BackgroundUrl", "someurl" },
2222
{ "Introduction:ProfilePictureUrl", "anotherurl" },
2323
{ "Introduction:Description", "desc" },
24+
{ "BlogPostsPerPage", "5" },
2425
};
2526
var configuration = new ConfigurationBuilder()
2627
.AddInMemoryCollection(inMemorySettings)
@@ -38,6 +39,7 @@ public void ShouldMapFromAppConfiguration()
3839
appConfiguration.Introduction.BackgroundUrl.Should().Be("someurl");
3940
appConfiguration.Introduction.ProfilePictureUrl.Should().Be("anotherurl");
4041
appConfiguration.Introduction.Description.Should().Be("desc");
42+
appConfiguration.BlogPostsPerPage.Should().Be(5);
4143
}
4244

4345
[Fact]
@@ -48,6 +50,7 @@ public void ShouldSetGithubLinkedAccountAccordingToValueSet()
4850
{ "Introduction:BackgroundUrl", "someurl" },
4951
{ "Introduction:ProfilePictureUrl", "anotherurl" },
5052
{ "Introduction:Description", "desc" },
53+
{ "BlogPostsPerPage", "2" },
5154
};
5255
var configuration = new ConfigurationBuilder()
5356
.AddInMemoryCollection(inMemorySettings)

LinkDotNet.Blog.Web/AppConfiguration.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ public record AppConfiguration
1919
public string ConnectionString { get; init; }
2020

2121
public string DatabaseName { get; init; }
22+
23+
public int BlogPostsPerPage { get; init; }
2224
}
2325
}

LinkDotNet.Blog.Web/AppConfigurationFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public static AppConfiguration Create(IConfiguration config)
1515
Introduction = config.GetSection("Introduction").Get<Introduction>(),
1616
ConnectionString = config["ConnectionString"],
1717
DatabaseName = config["DatabaseName"],
18+
BlogPostsPerPage = int.Parse(config["BlogPostsPerPage"]),
1819
};
1920
return configuration;
2021
}

LinkDotNet.Blog.Web/Pages/Index.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
protected override async Task OnInitializedAsync()
2828
{
29-
_currentPage = await _repository.GetAllAsync(p => p.IsPublished, b => b.UpdatedDate, pageSize: 10);
29+
_currentPage = await _repository.GetAllAsync(p => p.IsPublished, b => b.UpdatedDate, pageSize: _appConfiguration.BlogPostsPerPage);
3030
}
3131

3232
private string GetAbsolutePreviewImageUrl()
@@ -48,7 +48,7 @@
4848

4949
private async Task GetPage(int newPage)
5050
{
51-
_currentPage = await _repository.GetAllAsync(p => p.IsPublished, b => b.UpdatedDate, pageSize: 10, page:
51+
_currentPage = await _repository.GetAllAsync(p => p.IsPublished, b => b.UpdatedDate, pageSize: _appConfiguration.BlogPostsPerPage, page:
5252
newPage);
5353
}
5454
}

LinkDotNet.Blog.Web/Shared/AccessControl.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<a class="dropdown-item item" href="create">Create new</a>
99
<a class="dropdown-item item" href="draft">Show drafts</a>
1010
<div class="dropdown-divider"></div>
11-
<a class="dropdown-item disabled item" href="#">Version 1.2</a>
11+
<a class="dropdown-item disabled item" href="#">Version 1.3</a>
1212
</div>
1313
</div>
1414
</li>

LinkDotNet.Blog.Web/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
"Domain": "",
2222
"ClientId": "",
2323
"ClientSecret": ""
24-
}
24+
},
25+
"BlogPostsPerPage": 10
2526
}

Readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ The appsettings.json file has a lot of options to customize the content of the b
2929
"Domain": "",
3030
"ClientId": "",
3131
"ClientSecret": ""
32-
}
32+
},
33+
"BlogPostsPerPage": 10,
3334
}
3435

3536
```
@@ -49,6 +50,7 @@ The appsettings.json file has a lot of options to customize the content of the b
4950
| Domain | string | See more details here: https://manage.auth0.com/dashboard/ |
5051
| ClientId | string | See more details here: https://manage.auth0.com/dashboard/ |
5152
| ClientSecret | string | See more details here: https://manage.auth0.com/dashboard/ |
53+
| BlogPostsPerPage | int | Gives the amount of blog posts loaded and display per page. For more the user has to use the navigation |
5254

5355
The usage might shift directly into the extension methods, where they are used.
5456

0 commit comments

Comments
 (0)