Skip to content

Commit 42dffb3

Browse files
committed
Clean up in MVC code
1 parent da6b4bf commit 42dffb3

File tree

8 files changed

+3
-133
lines changed

8 files changed

+3
-133
lines changed

src/App/Controllers/BlogController.cs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Microsoft.AspNetCore.Authorization;
55
using Microsoft.AspNetCore.Identity;
66
using Microsoft.AspNetCore.Mvc;
7-
using Microsoft.AspNetCore.Mvc.ViewEngines;
87
using System.Linq;
98
using System.Threading.Tasks;
109
using System.Xml;
@@ -14,17 +13,13 @@ namespace App.Controllers
1413
[ApiExplorerSettings(IgnoreApi = true)]
1514
public class BlogController : Controller
1615
{
17-
IDataService _db;
1816
IFeedService _ss;
1917
SignInManager<AppUser> _sm;
20-
private readonly ICompositeViewEngine _viewEngine;
2118

22-
public BlogController(IDataService db, IFeedService ss, SignInManager<AppUser> sm, ICompositeViewEngine viewEngine)
19+
public BlogController(IFeedService ss, SignInManager<AppUser> sm)
2320
{
24-
_db = db;
2521
_ss = ss;
2622
_sm = sm;
27-
_viewEngine = viewEngine;
2823
}
2924

3025
[HttpGet("feed/{type}")]
@@ -51,27 +46,6 @@ public async Task Rss(string type)
5146
}
5247
}
5348

54-
[HttpGet("error/{code:int}")]
55-
public async Task<IActionResult> Error(int code)
56-
{
57-
var model = new PostModel();
58-
59-
model.Blog = await _db.CustomFields.GetBlogSettings();
60-
model.Blog.Cover = $"{Url.Content("~/")}{model.Blog.Cover}";
61-
62-
var viewName = $"~/Views/Shared/Error.cshtml";
63-
var result = _viewEngine.GetView("", viewName, false);
64-
65-
if (result.Success)
66-
{
67-
return View(viewName, model);
68-
}
69-
else
70-
{
71-
return View("~/Views/Shared/_Error.cshtml", model);
72-
}
73-
}
74-
7549
[HttpGet("admin")]
7650
[Authorize]
7751
public IActionResult Admin()

src/App/Views/Shared/Error.cshtml

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/App/Views/Shared/Footer.cshtml

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/App/Views/Shared/Head.cshtml

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/App/Views/Shared/Header.cshtml

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/App/Views/_ViewImports.cshtml

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/Core/Api/SettingsController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public async Task<IEnumerable<ImportMessage>> ImportFeed(IFormFile file)
113113
var author = _data.Authors.Single(a => a.AppUserName == User.Identity.Name);
114114

115115
if (!author.IsAdmin)
116-
Redirect("~/pages/shared/_error/403");
116+
throw new ApplicationException("Unauthorized");
117117

118118
var webRoot = Url.Content("~/");
119119

src/Core/Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp2.2</TargetFramework>
5-
<Version>2.4.1.5</Version>
5+
<Version>2.4.1.6</Version>
66
</PropertyGroup>
77

88
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

0 commit comments

Comments
 (0)