mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-30 01:35:32 +00:00
Formatted everything; completed upload capabilities
This commit is contained in:
@@ -4,23 +4,20 @@ using HaDocument.Interfaces;
|
||||
using HaXMLReader.Interfaces;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
|
||||
public class AdminController : Controller
|
||||
{
|
||||
public class AdminController : Controller {
|
||||
// DI
|
||||
private ILibrary _lib;
|
||||
private IReaderService _readerService;
|
||||
|
||||
public AdminController(ILibrary lib, IReaderService readerService)
|
||||
{
|
||||
public AdminController(ILibrary lib, IReaderService readerService) {
|
||||
_lib = lib;
|
||||
_readerService = readerService;
|
||||
}
|
||||
|
||||
|
||||
[Route("Admin")]
|
||||
[FeatureGate(Features.AdminService)]
|
||||
public IActionResult Index()
|
||||
{
|
||||
[FeatureGate(Features.AdminService)]
|
||||
public IActionResult Index() {
|
||||
return Redirect("/Admin/Upload");
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,7 @@ using HaDocument.Models;
|
||||
|
||||
namespace HaWeb.Controllers;
|
||||
|
||||
public class Briefecontroller : Controller
|
||||
{
|
||||
public class Briefecontroller : Controller {
|
||||
[BindProperty(SupportsGet = true)]
|
||||
public string? id { get; set; }
|
||||
|
||||
@@ -16,16 +15,14 @@ public class Briefecontroller : Controller
|
||||
private ILibrary _lib;
|
||||
private IReaderService _readerService;
|
||||
|
||||
public Briefecontroller(ILibrary lib, IReaderService readerService)
|
||||
{
|
||||
public Briefecontroller(ILibrary lib, IReaderService readerService) {
|
||||
_lib = lib;
|
||||
_readerService = readerService;
|
||||
}
|
||||
|
||||
[Route("Briefe")]
|
||||
[Route("Briefe/{id?}")]
|
||||
public IActionResult Index(string? id)
|
||||
{
|
||||
public IActionResult Index(string? id) {
|
||||
// Setup settings and variables
|
||||
var url = "/Briefe/";
|
||||
var defaultID = "1";
|
||||
@@ -73,25 +70,22 @@ public class Briefecontroller : Controller
|
||||
model.MetaData.ParsedZHString += " / " + parsedLetter.Startline;
|
||||
if (model.ParsedText == null || String.IsNullOrWhiteSpace(model.ParsedText))
|
||||
model.MetaData.HasText = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
return View(model);
|
||||
}
|
||||
|
||||
private IActionResult error404()
|
||||
{
|
||||
private IActionResult error404() {
|
||||
Response.StatusCode = 404;
|
||||
return Redirect("/Error404");
|
||||
}
|
||||
|
||||
private BriefeMetaViewModel generateMetaViewModel(Meta meta, bool hasMarginals)
|
||||
{
|
||||
private BriefeMetaViewModel generateMetaViewModel(Meta meta, bool hasMarginals) {
|
||||
var senders = meta.Senders.Select(x => _lib.Persons[x].Name) ?? new List<string>();
|
||||
var recivers = meta.Receivers.Select(x => _lib.Persons[x].Name) ?? new List<string>();
|
||||
var zhstring = meta.ZH != null ? HaWeb.HTMLHelpers.LetterHelpers.CreateZHString(meta) : null;
|
||||
return new BriefeMetaViewModel(meta, hasMarginals, false)
|
||||
{
|
||||
return new BriefeMetaViewModel(meta, hasMarginals, false) {
|
||||
ParsedZHString = zhstring,
|
||||
ParsedSenders = HTMLHelpers.StringHelpers.GetEnumerationString(senders),
|
||||
ParsedReceivers = HTMLHelpers.StringHelpers.GetEnumerationString(recivers)
|
||||
|
||||
@@ -5,40 +5,32 @@ using HaWeb.Models;
|
||||
namespace HaWeb.Controllers;
|
||||
|
||||
[Route("Edition/[action]")]
|
||||
public class EditionController : Controller
|
||||
{
|
||||
public class EditionController : Controller {
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
public IActionResult Error() {
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
public IActionResult Kontakt()
|
||||
{
|
||||
public IActionResult Kontakt() {
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Mitwirkende()
|
||||
{
|
||||
public IActionResult Mitwirkende() {
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Richtlinien()
|
||||
{
|
||||
public IActionResult Richtlinien() {
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Werkausgabe()
|
||||
{
|
||||
public IActionResult Werkausgabe() {
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Editionsgeschichte()
|
||||
{
|
||||
public IActionResult Editionsgeschichte() {
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Datenschutzerklaerung()
|
||||
{
|
||||
public IActionResult Datenschutzerklaerung() {
|
||||
return View();
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,7 @@ using HaWeb.Models;
|
||||
namespace HaWeb.Controllers;
|
||||
|
||||
|
||||
public class ErrorController : Controller
|
||||
{
|
||||
public class ErrorController : Controller {
|
||||
[Route("Error404/")]
|
||||
public IActionResult ErrorNotFound() {
|
||||
return View();
|
||||
|
||||
@@ -4,18 +4,15 @@ using HaWeb.Models;
|
||||
|
||||
namespace HaWeb.Controllers;
|
||||
|
||||
public class HomeController : Controller
|
||||
{
|
||||
public class HomeController : Controller {
|
||||
|
||||
[Route("")]
|
||||
public IActionResult Index()
|
||||
{
|
||||
public IActionResult Index() {
|
||||
return Redirect("/Suche");
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
public IActionResult Error() {
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,7 @@ using HaWeb.Models;
|
||||
namespace HaWeb.Controllers;
|
||||
|
||||
|
||||
public class LegacyContoller : Controller
|
||||
{
|
||||
public class LegacyContoller : Controller {
|
||||
[Route("Supplementa/")]
|
||||
[Route("Supplementa/Register")]
|
||||
[Route("Supplementa/Register/{id?}")]
|
||||
|
||||
@@ -12,8 +12,7 @@ using System.Collections.Concurrent;
|
||||
namespace HaWeb.Controllers;
|
||||
|
||||
[Route("Register/[action]/{id?}")]
|
||||
public class RegisterController : Controller
|
||||
{
|
||||
public class RegisterController : Controller {
|
||||
[BindProperty(SupportsGet = true)]
|
||||
public string? search { get; set; }
|
||||
|
||||
@@ -24,14 +23,12 @@ public class RegisterController : Controller
|
||||
private ILibrary _lib;
|
||||
private IReaderService _readerService;
|
||||
|
||||
public RegisterController(ILibrary lib, IReaderService readerService)
|
||||
{
|
||||
public RegisterController(ILibrary lib, IReaderService readerService) {
|
||||
_lib = lib;
|
||||
_readerService = readerService;
|
||||
}
|
||||
|
||||
public IActionResult Register(string? id)
|
||||
{
|
||||
public IActionResult Register(string? id) {
|
||||
// Setup settings and variables
|
||||
var url = "/Register/Register/";
|
||||
var category = "neuzeit";
|
||||
@@ -52,15 +49,12 @@ public class RegisterController : Controller
|
||||
|
||||
// Parsing
|
||||
var res = new List<CommentModel>();
|
||||
foreach (var comm in comments)
|
||||
{
|
||||
foreach (var comm in comments) {
|
||||
var parsedComment = HTMLHelpers.CommentHelpers.CreateHTML(_lib, _readerService, comm, category, Settings.ParsingState.CommentType.Comment);
|
||||
List<string>? parsedSubComments = null;
|
||||
if (comm.Kommentare != null)
|
||||
{
|
||||
if (comm.Kommentare != null) {
|
||||
parsedSubComments = new List<string>();
|
||||
foreach (var subcomm in comm.Kommentare.OrderBy(x => x.Value.Order))
|
||||
{
|
||||
foreach (var subcomm in comm.Kommentare.OrderBy(x => x.Value.Order)) {
|
||||
parsedSubComments.Add(HTMLHelpers.CommentHelpers.CreateHTML(_lib, _readerService, subcomm.Value, category, Settings.ParsingState.CommentType.Subcomment));
|
||||
}
|
||||
}
|
||||
@@ -68,8 +62,7 @@ public class RegisterController : Controller
|
||||
}
|
||||
|
||||
// Model instantiation
|
||||
var model = new RegisterViewModel(category, this.id, res, title)
|
||||
{
|
||||
var model = new RegisterViewModel(category, this.id, res, title) {
|
||||
AvailableCategories = availableCategories,
|
||||
};
|
||||
|
||||
@@ -77,8 +70,7 @@ public class RegisterController : Controller
|
||||
return View("Index", model);
|
||||
}
|
||||
|
||||
public IActionResult Bibelstellen(string? id)
|
||||
{
|
||||
public IActionResult Bibelstellen(string? id) {
|
||||
// Setup settings and variables
|
||||
var url = "/Register/Bibelstellen/";
|
||||
var category = "bibel";
|
||||
@@ -91,7 +83,7 @@ public class RegisterController : Controller
|
||||
if (id == null) return Redirect(url + defaultLetter);
|
||||
normalizeID(id, defaultLetter);
|
||||
if (this.id != "AT" && this.id != "AP" && this.id != "NT") return error404();
|
||||
|
||||
|
||||
// Data aquisition and validation
|
||||
var comments = _lib.CommentsByCategory[category].ToLookup(x => x.Index.Substring(0, 2).ToUpper())[this.id].OrderBy(x => x.Order);
|
||||
var availableCategories = new List<(string, string)>() { ("Altes Testament", url + "AT"), ("Apogryphen", url + "AP"), ("Neues Testament", url + "NT") };
|
||||
@@ -99,15 +91,12 @@ public class RegisterController : Controller
|
||||
|
||||
// Parsing
|
||||
var res = new List<CommentModel>();
|
||||
foreach (var comm in comments)
|
||||
{
|
||||
foreach (var comm in comments) {
|
||||
var parsedComment = HTMLHelpers.CommentHelpers.CreateHTML(_lib, _readerService, comm, category, Settings.ParsingState.CommentType.Comment);
|
||||
List<string>? parsedSubComments = null;
|
||||
if (comm.Kommentare != null)
|
||||
{
|
||||
if (comm.Kommentare != null) {
|
||||
parsedSubComments = new List<string>();
|
||||
foreach (var subcomm in comm.Kommentare.OrderBy(x => x.Value.Lemma.Length).ThenBy(x => x.Value.Lemma))
|
||||
{
|
||||
foreach (var subcomm in comm.Kommentare.OrderBy(x => x.Value.Lemma.Length).ThenBy(x => x.Value.Lemma)) {
|
||||
parsedSubComments.Add(HTMLHelpers.CommentHelpers.CreateHTML(_lib, _readerService, subcomm.Value, category, Settings.ParsingState.CommentType.Subcomment));
|
||||
}
|
||||
}
|
||||
@@ -115,8 +104,7 @@ public class RegisterController : Controller
|
||||
}
|
||||
|
||||
// Model instantiation
|
||||
var model = new RegisterViewModel(category, this.id, res, title)
|
||||
{
|
||||
var model = new RegisterViewModel(category, this.id, res, title) {
|
||||
AvailableCategories = availableCategories,
|
||||
};
|
||||
|
||||
@@ -124,8 +112,7 @@ public class RegisterController : Controller
|
||||
return View("Index", model);
|
||||
}
|
||||
|
||||
public IActionResult Forschung(string? id)
|
||||
{
|
||||
public IActionResult Forschung(string? id) {
|
||||
// Setup settings and variables
|
||||
var url = "/Register/Forschung/";
|
||||
var category = "forschung";
|
||||
@@ -139,13 +126,12 @@ public class RegisterController : Controller
|
||||
normalizeID(id, defaultLetter);
|
||||
if (this.id != "EDITIONEN" && !_lib.CommentsByCategoryLetter[category].Contains(this.id)) return error404();
|
||||
if (this.id == "EDITIONEN" && !_lib.CommentsByCategoryLetter.Keys.Contains(this.id.ToLower())) return error404();
|
||||
|
||||
|
||||
// Data aquisition and validation
|
||||
IOrderedEnumerable<Comment>? comments = null;
|
||||
if (this.id == "EDITIONEN") {
|
||||
comments = _lib.CommentsByCategory[this.id.ToLower()].OrderBy(x => x.Index);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
comments = _lib.CommentsByCategoryLetter[category][this.id].OrderBy(x => x.Index);
|
||||
}
|
||||
var availableCategories = _lib.CommentsByCategoryLetter[category].Select(x => (x.Key.ToUpper(), url + x.Key.ToUpper())).OrderBy(x => x.Item1).ToList();
|
||||
@@ -154,15 +140,12 @@ public class RegisterController : Controller
|
||||
|
||||
// Parsing
|
||||
var res = new List<CommentModel>();
|
||||
foreach (var comm in comments)
|
||||
{
|
||||
foreach (var comm in comments) {
|
||||
var parsedComment = HTMLHelpers.CommentHelpers.CreateHTML(_lib, _readerService, comm, category, Settings.ParsingState.CommentType.Comment);
|
||||
List<string>? parsedSubComments = null;
|
||||
if (comm.Kommentare != null)
|
||||
{
|
||||
if (comm.Kommentare != null) {
|
||||
parsedSubComments = new List<string>();
|
||||
foreach (var subcomm in comm.Kommentare.OrderBy(x => x.Value.Order))
|
||||
{
|
||||
foreach (var subcomm in comm.Kommentare.OrderBy(x => x.Value.Order)) {
|
||||
parsedSubComments.Add(HTMLHelpers.CommentHelpers.CreateHTML(_lib, _readerService, subcomm.Value, category, Settings.ParsingState.CommentType.Subcomment));
|
||||
}
|
||||
}
|
||||
@@ -170,8 +153,7 @@ public class RegisterController : Controller
|
||||
}
|
||||
|
||||
// Model instantiation
|
||||
var model = new RegisterViewModel(category, this.id, res, title)
|
||||
{
|
||||
var model = new RegisterViewModel(category, this.id, res, title) {
|
||||
AvailableCategories = availableCategories,
|
||||
AvailableSideCategories = AvailableSideCategories
|
||||
};
|
||||
@@ -180,22 +162,18 @@ public class RegisterController : Controller
|
||||
return View("Index", model);
|
||||
}
|
||||
|
||||
private void normalizeID(string? id, string defaultid)
|
||||
{
|
||||
private void normalizeID(string? id, string defaultid) {
|
||||
this.id = this.id.ToUpper();
|
||||
}
|
||||
|
||||
private bool validationCheck(HashSet<string> permitted)
|
||||
{
|
||||
if (!permitted.Contains(id))
|
||||
{
|
||||
private bool validationCheck(HashSet<string> permitted) {
|
||||
if (!permitted.Contains(id)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private IActionResult error404()
|
||||
{
|
||||
private IActionResult error404() {
|
||||
Response.StatusCode = 404;
|
||||
return Redirect("/Error404");
|
||||
}
|
||||
|
||||
@@ -4,18 +4,15 @@ using HaWeb.Models;
|
||||
|
||||
namespace HaWeb.Controllers;
|
||||
|
||||
public class SucheController : Controller
|
||||
{
|
||||
public class SucheController : Controller {
|
||||
|
||||
[Route("Suche")]
|
||||
public IActionResult Index()
|
||||
{
|
||||
public IActionResult Index() {
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
public IActionResult Error() {
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,12 @@ using HaDocument.Interfaces;
|
||||
using HaXMLReader.Interfaces;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
|
||||
public class UpdateController : Controller
|
||||
{
|
||||
public class UpdateController : Controller {
|
||||
// DI
|
||||
private ILibrary _lib;
|
||||
private IReaderService _readerService;
|
||||
|
||||
public UpdateController(ILibrary lib, IReaderService readerService)
|
||||
{
|
||||
public UpdateController(ILibrary lib, IReaderService readerService) {
|
||||
_lib = lib;
|
||||
_readerService = readerService;
|
||||
}
|
||||
@@ -19,8 +17,7 @@ public class UpdateController : Controller
|
||||
|
||||
[Route("Admin/Update")]
|
||||
[FeatureGate(Features.UpdateService)]
|
||||
public IActionResult Index()
|
||||
{
|
||||
public IActionResult Index() {
|
||||
return View("../Admin/Upload/Index");
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,7 @@ using System.Xml.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.Json;
|
||||
|
||||
public class UploadController : Controller
|
||||
{
|
||||
public class UploadController : Controller {
|
||||
// DI
|
||||
private ILibrary _lib;
|
||||
private IReaderService _readerService;
|
||||
@@ -35,8 +34,7 @@ public class UploadController : Controller
|
||||
private static readonly FormOptions _defaultFormOptions = new FormOptions();
|
||||
|
||||
|
||||
public UploadController(ILibrary lib, IReaderService readerService, IXMLService xmlService, IConfiguration config)
|
||||
{
|
||||
public UploadController(ILibrary lib, IReaderService readerService, IXMLService xmlService, IConfiguration config) {
|
||||
_lib = lib;
|
||||
_readerService = readerService;
|
||||
_xmlService = xmlService;
|
||||
@@ -49,27 +47,28 @@ public class UploadController : Controller
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("Admin/Upload")]
|
||||
[Route("Admin/Upload/{id?}")]
|
||||
[FeatureGate(Features.UploadService)]
|
||||
[GenerateAntiforgeryTokenCookie]
|
||||
public IActionResult Index()
|
||||
{
|
||||
public IActionResult Index(string? id) {
|
||||
var model = new UploadViewModel();
|
||||
model.AvailableRoots = _xmlService.GetRoots().Select(x => (x.Type, "")).ToList();
|
||||
model.AvailableRoots = _xmlService.GetRoots();
|
||||
model.UsedFiles = _xmlService.GetUsed();
|
||||
var hello = "mama";
|
||||
return View("../Admin/Upload/Index", model);
|
||||
}
|
||||
|
||||
|
||||
//// UPLOAD ////
|
||||
//// UPLOAD ////
|
||||
[HttpPost]
|
||||
[Route("Admin/Upload")]
|
||||
[DisableFormValueModelBinding]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Post() {
|
||||
//// 1. Stage: Check Request format and request spec
|
||||
List<XMLRootDocument>? docs = null;
|
||||
//// 1. Stage: Check Request format and request spec
|
||||
// Checks the Content-Type Field (must be multipart + Boundary)
|
||||
if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType))
|
||||
{
|
||||
if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType)) {
|
||||
ModelState.AddModelError("Error", $"Wrong / No Content Type on the Request");
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
@@ -80,80 +79,63 @@ public class UploadController : Controller
|
||||
MultipartSection? section = null;
|
||||
try {
|
||||
section = await reader.ReadNextSectionAsync();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
ModelState.AddModelError("Error", "The Request is bad: " + ex.Message);
|
||||
}
|
||||
|
||||
while (section != null)
|
||||
{
|
||||
while (section != null) {
|
||||
// Multipart document content disposition header read for a section:
|
||||
// Starts with boundary, contains field name, content-dispo, filename, content-type
|
||||
var hasContentDispositionHeader = ContentDispositionHeaderValue.TryParse(section.ContentDisposition, out var contentDisposition);
|
||||
if (hasContentDispositionHeader && contentDisposition != null)
|
||||
{
|
||||
if (hasContentDispositionHeader && contentDisposition != null) {
|
||||
// Checks if it is a section with content-disposition, name, filename
|
||||
if (!MultipartRequestHelper.HasFileContentDisposition(contentDisposition))
|
||||
{
|
||||
if (!MultipartRequestHelper.HasFileContentDisposition(contentDisposition)) {
|
||||
ModelState.AddModelError("Error", $"Wrong Content-Dispostion Headers in Multipart Document");
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
//// 2. Stage: Check File. Sanity checks on the file on a byte level, extension checking, is it empty etc.
|
||||
//// 2. Stage: Check File. Sanity checks on the file on a byte level, extension checking, is it empty etc.
|
||||
var streamedFileContent = await XMLFileHelpers.ProcessStreamedFile(
|
||||
section, contentDisposition, ModelState,
|
||||
section, contentDisposition, ModelState,
|
||||
_permittedExtensions, _fileSizeLimit);
|
||||
if (!ModelState.IsValid || streamedFileContent == null)
|
||||
return BadRequest(ModelState);
|
||||
|
||||
//// 3. Stage: Valid XML checking using a simple XDocument.Load()
|
||||
//// 3. Stage: Valid XML checking using a simple XDocument.Load()
|
||||
var xdocument = await XDocumentFileHelper.ProcessStreamedFile(streamedFileContent, ModelState);
|
||||
if (!ModelState.IsValid || xdocument == null)
|
||||
return UnprocessableEntity(ModelState);
|
||||
|
||||
//// 4. Stage: Is it a Hamann-Document? What kind?
|
||||
var docs = _xmlService.ProbeHamannFile(xdocument, ModelState);
|
||||
if (!ModelState.IsValid || docs == null || !docs.Any())
|
||||
//// 4. Stage: Is it a Hamann-Document? What kind?
|
||||
var retdocs = await _xmlService.ProbeHamannFile(xdocument, ModelState);
|
||||
if (!ModelState.IsValid || retdocs == null || !retdocs.Any())
|
||||
return UnprocessableEntity(ModelState);
|
||||
|
||||
//// 5. Stage: Saving the File(s)
|
||||
foreach (var doc in docs) {
|
||||
var type = doc.Prefix;
|
||||
var directory = Path.Combine(_targetFilePath, type);
|
||||
if (!Directory.Exists(directory))
|
||||
Directory.CreateDirectory(directory);
|
||||
var path = Path.Combine(directory, doc.FileName);
|
||||
try {
|
||||
using (var targetStream = System.IO.File.Create(path))
|
||||
await doc.Save(targetStream, ModelState);
|
||||
if (!ModelState.IsValid) return StatusCode(500, ModelState);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ModelState.AddModelError("Error", "Speichern der Datei fehlgeschlagen: " + ex.Message);
|
||||
return StatusCode(500, ModelState);
|
||||
}
|
||||
|
||||
//// 5. Stage: Saving the File(s)
|
||||
foreach (var doc in retdocs) {
|
||||
await _xmlService.UpdateAvailableFiles(doc, _targetFilePath, ModelState);
|
||||
if (!ModelState.IsValid) return StatusCode(500, ModelState);
|
||||
if (docs == null) docs = new List<XMLRootDocument>();
|
||||
docs.Add(doc);
|
||||
}
|
||||
|
||||
// 6. State: Returning Ok, and redirecting
|
||||
JsonSerializerOptions options = new() {
|
||||
ReferenceHandler = ReferenceHandler.Preserve
|
||||
};
|
||||
|
||||
string json = JsonSerializer.Serialize(docs);
|
||||
return Created(nameof(UploadController), json);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
section = await reader.ReadNextSectionAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
ModelState.AddModelError("Error", "The Request is bad: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
//// Success! Return Last Created File View
|
||||
return Created(nameof(UploadController), null);
|
||||
// 6. Stage: Success! Returning Ok, and redirecting
|
||||
JsonSerializerOptions options = new() {
|
||||
ReferenceHandler = ReferenceHandler.Preserve,
|
||||
Converters = {
|
||||
new IdentificationStringJSONConverter()
|
||||
}
|
||||
};
|
||||
|
||||
string json = JsonSerializer.Serialize(docs);
|
||||
return Created(nameof(UploadController), json);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user