From b48b8dbb6cebb88367992a7472883ea25106dc42 Mon Sep 17 00:00:00 2001 From: ivanszabo Date: Thu, 20 Mar 2025 13:20:00 +0100 Subject: [PATCH] Location is. --- .../Locations/LocationEditPage.cshtml | 87 +++++++++++++++++++ .../Locations/LocationEditPage.cshtml.cs | 39 ++++++++- .../BaseStock/Locations/LocationsPage.cshtml | 9 +- 3 files changed, 133 insertions(+), 2 deletions(-) diff --git a/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationEditPage.cshtml b/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationEditPage.cshtml index aebff94..7a92a9a 100644 --- a/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationEditPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationEditPage.cshtml @@ -1,4 +1,91 @@ @page @model WorkFlowCheck.Web.Pages.BaseStock.Locations.LocationEditPageModel +@using Microsoft.AspNetCore.Antiforgery +@inject IAntiforgery Antiforgery @{ + ViewData["Title"] = "Lokáció"; + var LocationId = Model.LocationDTO.Id; + var urlPost = Url.Page("./LocationEditPage", "Save"); +} +

@ViewData["Title"]

+ + + +
+
+ + +
+ + + +
+
+ + +
+
+
+ +@section Scripts { + } diff --git a/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationEditPage.cshtml.cs b/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationEditPage.cshtml.cs index eaa730d..60b1553 100644 --- a/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationEditPage.cshtml.cs +++ b/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationEditPage.cshtml.cs @@ -1,12 +1,49 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; +using Serilog; +using WorkFlowCheck.Common.DTO; +using WorkFlowCheck.Web.Services.Interfaces; namespace WorkFlowCheck.Web.Pages.BaseStock.Locations { public class LocationEditPageModel : PageModel { - public void OnGet() + private readonly ILogger _logger; + private readonly IBaseStockService _baseStockService; + + [BindProperty] + public LocationDTO LocationDTO { get; set; } + + public LocationEditPageModel(ILogger logger, IBaseStockService baseStockService) { + _baseStockService = baseStockService; + _logger = logger; + } + + public async Task OnGet(int id) + { + LocationDTO = await _baseStockService.GetLocation(id); + } + public async Task OnPostSave([FromBody] LocationDTO LocationDTO) + { + try + { + var result = await _baseStockService.UpdateLocation(LocationDTO); + if (result.IsSuccess) + { + return new JsonResult(new { success = true }); + } + else + { + return new JsonResult(new { success = false }); + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + + return new JsonResult(new { success = false }); } } } diff --git a/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationsPage.cshtml b/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationsPage.cshtml index 15576b1..27519c3 100644 --- a/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationsPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationsPage.cshtml @@ -7,7 +7,9 @@
- +
@@ -58,6 +60,11 @@ language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',} }); + $('#newLocationBtn').on('click', function () + { + window.location.href = `@Url.Page("/BaseStock/Locations/LocationEditPage")?id=0`; + }); + $('#tbLocationsPage').on('click', '.edit-btn', function () { const row = table.row($(this).closest('tr')).data();