From 075283f88484fb2de0d1feaaf9082e1daaa992e0 Mon Sep 17 00:00:00 2001 From: Tracy Pearson Date: Sat, 10 Dec 2022 02:51:51 -0500 Subject: [PATCH] Functional partialview via ajax --- .gitignore | 3 +++ Caddy/Caddyfile | 15 +++++++++++++++ .../Controllers/HomeController.cs | 9 ++++++--- WebPostPartialJsonObject/Models/ReprintInfo.cs | 16 ++++++++++------ .../Views/Home/ReprintView.cshtml | 5 +++-- 5 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 Caddy/Caddyfile diff --git a/.gitignore b/.gitignore index 9491a2f..612e319 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,9 @@ ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore +Caddy/* +!Caddyfile + # User-specific files *.rsuser *.suo diff --git a/Caddy/Caddyfile b/Caddy/Caddyfile new file mode 100644 index 0000000..86058f5 --- /dev/null +++ b/Caddy/Caddyfile @@ -0,0 +1,15 @@ +{ + log { + output stderr + format json { + time_local + time_format wall_milli + duration_format string + } + } +} + +http://*:9000 { + reverse_proxy localhost:5000 + log +} diff --git a/WebPostPartialJsonObject/Controllers/HomeController.cs b/WebPostPartialJsonObject/Controllers/HomeController.cs index c1eafb1..e8fbbe8 100644 --- a/WebPostPartialJsonObject/Controllers/HomeController.cs +++ b/WebPostPartialJsonObject/Controllers/HomeController.cs @@ -29,10 +29,13 @@ namespace WebPostPartialJsonObject.Controllers HttpContext.Session.SetObject("KioskSettings", data); return RedirectToAction("Index", "Settings"); } - [HttpPost, Consumes("application/json")] - public IActionResult Reprint(int ckinid) + [HttpPost] + public IActionResult Reprint([FromForm]int ckinid) { - return PartialView("Reprint"); + ReprintInfo model = new ReprintInfo(); + model.CkInId = ckinid; + model.PrinterName = "printer"; + return PartialView("ReprintView", model); } public IActionResult Privacy() diff --git a/WebPostPartialJsonObject/Models/ReprintInfo.cs b/WebPostPartialJsonObject/Models/ReprintInfo.cs index 1c64d00..5d458f6 100644 --- a/WebPostPartialJsonObject/Models/ReprintInfo.cs +++ b/WebPostPartialJsonObject/Models/ReprintInfo.cs @@ -1,10 +1,14 @@ using System.Collections; using System.Collections.Generic; - -public class ReprintInfo +namespace WebPostPartialJsonObject.Models { - public IEnumerable LabelSets { get; set; } - public IEnumerable LabelNames { get; set; } - public int PrinterType { get; set; } - public string PrinterName { get; set; } + + public class ReprintInfo + { + public IEnumerable LabelSets { get; set; } + public IEnumerable LabelNames { get; set; } + public int PrinterType { get; set; } + public string PrinterName { get; set; } + public int CkInId { get; set; } + } } \ No newline at end of file diff --git a/WebPostPartialJsonObject/Views/Home/ReprintView.cshtml b/WebPostPartialJsonObject/Views/Home/ReprintView.cshtml index 7e42232..44625ff 100644 --- a/WebPostPartialJsonObject/Views/Home/ReprintView.cshtml +++ b/WebPostPartialJsonObject/Views/Home/ReprintView.cshtml @@ -1,8 +1,9 @@ @* For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 *@ +@model WebPostPartialJsonObject.Models.ReprintInfo @{ - + } -

Partial View

+

Partial View @Model.CkInId