|
11 | 11 | using Microsoft.AspNetCore.Mvc;
|
12 | 12 | using Microsoft.Extensions.Caching.Memory;
|
13 | 13 | using Microsoft.Extensions.Logging;
|
| 14 | +using Quartz.Util; |
14 | 15 | using System;
|
| 16 | +using System.Collections.Generic; |
15 | 17 | using System.Diagnostics;
|
16 | 18 | using System.Linq;
|
17 |
| -using System.Threading.Tasks; |
18 | 19 |
|
19 | 20 | namespace DasBlog.Web.Controllers
|
20 | 21 | {
|
@@ -47,9 +48,7 @@ public IActionResult Index()
|
47 | 48 | {
|
48 | 49 | lpvm = new ListPostsViewModel
|
49 | 50 | {
|
50 |
| - Posts = blogManager.GetFrontPagePosts(Request.Headers["Accept-Language"]) |
51 |
| - .Select(entry => mapper.Map<PostViewModel>(entry)) |
52 |
| - .Select(editentry => editentry).ToList() |
| 51 | + Posts = HomePagePosts() |
53 | 52 | };
|
54 | 53 |
|
55 | 54 | foreach( var post in lpvm.Posts )
|
@@ -92,7 +91,6 @@ public IActionResult Page(int index)
|
92 | 91 | return Index();
|
93 | 92 | }
|
94 | 93 |
|
95 |
| - |
96 | 94 | var lpvm = new ListPostsViewModel
|
97 | 95 | {
|
98 | 96 | Posts = blogManager.GetEntriesForPage(index, Request.Headers["Accept-Language"])
|
@@ -157,6 +155,29 @@ private ListPostsViewModel AddComments(ListPostsViewModel listPostsViewModel)
|
157 | 155 |
|
158 | 156 | return listPostsViewModel;
|
159 | 157 | }
|
| 158 | + |
| 159 | + private IList<PostViewModel> HomePagePosts() |
| 160 | + { |
| 161 | + IList<PostViewModel> posts = new List<PostViewModel>(); |
| 162 | + |
| 163 | + if (!dasBlogSettings.SiteConfiguration.PostPinnedToHomePage.IsNullOrWhiteSpace() && |
| 164 | + Guid.TryParse(dasBlogSettings.SiteConfiguration.PostPinnedToHomePage, out var results)) |
| 165 | + { |
| 166 | + var entry = blogManager.GetBlogPostByGuid(results); |
| 167 | + |
| 168 | + if (entry != null) |
| 169 | + { |
| 170 | + posts.Add(mapper.Map<PostViewModel>(entry)); |
| 171 | + } |
| 172 | + } |
| 173 | + else |
| 174 | + { |
| 175 | + posts = blogManager.GetFrontPagePosts(Request.Headers["Accept-Language"]) |
| 176 | + .Select(entry => mapper.Map<PostViewModel>(entry)).ToList(); |
| 177 | + } |
| 178 | + |
| 179 | + return posts; |
| 180 | + } |
160 | 181 | }
|
161 | 182 | }
|
162 | 183 |
|
0 commit comments