mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 09:15:33 +00:00
Migitated some null risks
This commit is contained in:
@@ -52,7 +52,7 @@ public class APIController : Controller {
|
||||
[DisableFormValueModelBinding]
|
||||
[ValidateAntiForgeryToken]
|
||||
[FeatureGate(Features.UploadService, Features.AdminService)]
|
||||
public async Task<IActionResult> SyntaxCheck(string id) {
|
||||
public IActionResult SyntaxCheck(string id) {
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,9 +49,10 @@ public class RegisterController : Controller {
|
||||
ViewData["SEODescription"] = "Johann Georg Hamann: Kommentierte Briefausgabe. Personen-, Sach- und Ortsregister.";
|
||||
|
||||
// Normalisation and validation
|
||||
if (id == null) return Redirect(url + defaultLetter);
|
||||
if (String.IsNullOrWhiteSpace(id)) return Redirect(url + defaultLetter);
|
||||
id = normalizeID(id, defaultLetter);
|
||||
if (!lib.CommentsByCategoryLetter[category].Contains(id)) return error404();
|
||||
if (String.IsNullOrWhiteSpace(id)) return Redirect(url + defaultLetter);
|
||||
if (!lib.CommentsByCategoryLetter[category].Contains(id!)) return error404();
|
||||
|
||||
// Data aquisition and validation
|
||||
var comments = lib.CommentsByCategoryLetter[category][id].OrderBy(x => x.Index);
|
||||
@@ -115,8 +116,9 @@ public class RegisterController : Controller {
|
||||
ViewData["SEODescription"] = "Johann Georg Hamann: Kommentierte Briefausgabe. Forschungsbibliographie.";
|
||||
|
||||
// Normalisation and Validation
|
||||
if (id == null) return Redirect(url + defaultLetter);
|
||||
if (String.IsNullOrWhiteSpace(id)) return Redirect(url + defaultLetter);
|
||||
id = normalizeID(id, defaultLetter);
|
||||
if (String.IsNullOrWhiteSpace(id)) return Redirect(url + defaultLetter);
|
||||
if (id != "EDITIONEN" && !lib.CommentsByCategoryLetter[category].Contains(id)) return error404();
|
||||
if (id == "EDITIONEN" && !lib.CommentsByCategoryLetter.Keys.Contains(id.ToLower())) return error404();
|
||||
|
||||
@@ -175,6 +177,7 @@ public class RegisterController : Controller {
|
||||
private List<CommentModel> _createCommentModelForschungRegister(string category, IOrderedEnumerable<Comment>? comments) {
|
||||
var lib = _lib.GetLibrary();
|
||||
var res = new List<CommentModel>();
|
||||
if (comments == null) return res;
|
||||
foreach (var comm in comments) {
|
||||
var parsedComment = HTMLHelpers.CommentHelpers.CreateHTML(lib, _readerService, comm, category, Settings.ParsingState.CommentType.Comment);
|
||||
List<string>? parsedSubComments = null;
|
||||
@@ -192,6 +195,7 @@ public class RegisterController : Controller {
|
||||
private List<CommentModel> _createCommentModelBibel(string category, IOrderedEnumerable<Comment>? comments) {
|
||||
var lib = _lib.GetLibrary();
|
||||
var res = new List<CommentModel>();
|
||||
if (comments == null) return res;
|
||||
foreach (var comm in comments) {
|
||||
var parsedComment = HTMLHelpers.CommentHelpers.CreateHTML(lib, _readerService, comm, category, Settings.ParsingState.CommentType.Comment);
|
||||
List<string>? parsedSubComments = null;
|
||||
|
||||
@@ -68,8 +68,6 @@ public class SucheController : Controller {
|
||||
List<IGrouping<int, Meta>>? metasbyyear = null;
|
||||
if (search != null) {
|
||||
search = search.Trim();
|
||||
var sw = new System.Diagnostics.Stopwatch();
|
||||
sw.Start();
|
||||
var res = _lib.SearchLetters(search, _readerService);
|
||||
if (res == null || !res.Any()) return _error404();
|
||||
var ret = res.ToDictionary(
|
||||
@@ -80,8 +78,6 @@ public class SucheController : Controller {
|
||||
);
|
||||
var keys = res.Select(x => x.Index).Where(x => lib.Metas.ContainsKey(x)).Select(x => lib.Metas[x]);
|
||||
var letters = keys.ToLookup(x => x.Sort.Year).OrderBy(x => x.Key).ToList();
|
||||
sw.Stop();
|
||||
Console.WriteLine(sw.ElapsedMilliseconds);
|
||||
return _paginateSend(lib, page, letters, null, null, null, search, ret);
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class LinkHelper {
|
||||
reader.Tag += OnTag;
|
||||
}
|
||||
|
||||
private void OnTag(object _, Tag tag) {
|
||||
private void OnTag(object? _, Tag tag) {
|
||||
if (tag.Name == "wwwlink" || tag.Name == "intlink" || tag.Name == "link") {
|
||||
if (tag.EndTag && _followlinksinthis) {
|
||||
_sb.Append(HTMLHelpers.TagHelpers.CreateEndElement("a"));
|
||||
@@ -68,7 +68,7 @@ public class LinkHelper {
|
||||
}
|
||||
}
|
||||
if (tag.Name == "link" && tag.Values != null) {
|
||||
Comment comment = null;
|
||||
Comment? comment = null;
|
||||
if (tag.Values.ContainsKey("subref") && _lib.SubCommentsByID.ContainsKey(tag["subref"]))
|
||||
comment = _lib.SubCommentsByID[tag["subref"]];
|
||||
else if (tag.Values.ContainsKey("ref"))
|
||||
|
||||
@@ -13,5 +13,6 @@ public class FileModel {
|
||||
IsUsed = isUsed;
|
||||
LastModified = lastModified;
|
||||
InProduction = inProduction;
|
||||
Prefix = prefix;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
<div class="ha-searchhead">
|
||||
<h1>Briefauswahl</h1>
|
||||
<div class="ha-searchnav">
|
||||
@if (Model.AvailableYears != null && Model.AvailableYears.Any()) {
|
||||
@if (Model.AvailableYears != null && Model.AvailableYears.Any() && Model.AvailableYears.Count > 1) {
|
||||
@for(var i = 0; i < Model.AvailableYears.Count; i++) {
|
||||
<a class="@(Model.ActiveYear == i ? "active" : "")" asp-route-person="@Model.ActivePerson" asp-route-search="@Model.ActiveSearch" asp-controller="Suche" asp-route-page="@i">
|
||||
@if (Model.AvailableYears[i].StartYear != Model.AvailableYears[i].EndYear) {
|
||||
|
||||
Reference in New Issue
Block a user