From f22f2a9cdae8336f84555cef38958e49f8f5c6f0 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 8 Jun 2020 23:59:40 +0000 Subject: [PATCH] --- Controllers/MailController.cs | 9 +++++++-- Startup.cs | 5 ++--- rockfishCore.csproj | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Controllers/MailController.cs b/Controllers/MailController.cs index 1ee1adb..c6a5616 100644 --- a/Controllers/MailController.cs +++ b/Controllers/MailController.cs @@ -45,9 +45,14 @@ namespace rockfishCore.Controllers [HttpPost("reply/{account}/{id}")] - public JsonResult Reply([FromRoute] string account, [FromRoute] uint id, [FromBody] dtoReplyMessageItem m) + public ActionResult Reply([FromRoute] string account, [FromRoute] uint id, [FromBody] dtoReplyMessageItem m) { - if (string.IsNullOrWhiteSpace(m.composition)) + if (!ModelState.IsValid) + { + return BadRequest(); + } + + if (m==null || string.IsNullOrWhiteSpace(m.composition)) { return Json(new { msg = "MailController:Reply->There is no reply text", error = 1 }); } diff --git a/Startup.cs b/Startup.cs index 7d8fe12..e21d703 100644 --- a/Startup.cs +++ b/Startup.cs @@ -42,7 +42,7 @@ namespace rockfishCore // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddControllers(); + services.AddControllers().AddNewtonsoftJson(); services.AddDbContext(options => { options.UseSqlite(Configuration.GetConnectionString("rfdb")).EnableSensitiveDataLogging(false); @@ -111,9 +111,8 @@ namespace rockfishCore app.UseRouting(); app.UseAuthorization(); - app.UseEndpoints(endpoints => - { + { endpoints.MapControllers(); }); diff --git a/rockfishCore.csproj b/rockfishCore.csproj index a644f92..bc44b33 100644 --- a/rockfishCore.csproj +++ b/rockfishCore.csproj @@ -14,7 +14,7 @@ - + \ No newline at end of file