mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 17:25:32 +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);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user