Jóváhagyás utáni automatikus mail + CheckListHeader ShortName és Description javítása
This commit is contained in:
+29
-9
@@ -34,10 +34,17 @@
|
||||
<form method="post" id="CheckListHeaderForm">
|
||||
<meta name="csrf-token" content="@Antiforgery.GetAndStoreTokens(HttpContext).RequestToken" />
|
||||
<input type="hidden" asp-for="CheckListHeaderDTO.Id" />
|
||||
<input type="hidden" asp-for="CheckListHeaderDTO.IsEditable" />
|
||||
<input type="hidden" asp-for="CheckListHeaderDTO.IsStorno" />
|
||||
<input type="hidden" asp-for="CheckListHeaderDTO.GuidNumber" />
|
||||
<input type="hidden" asp-for="CheckListHeaderDTO.CheckListTemplateHeaderId" />
|
||||
<input type="hidden" asp-for="CheckListHeaderDTO.UserId" />
|
||||
<input type="hidden" name="CheckListHeaderDTO.DateExecution" value="@Model.CheckListHeaderDTO.DateExecution.ToString("yyyy-MM-dd")" />
|
||||
<input type="hidden" asp-for="CheckListHeaderDTO.AcceptUserId" />
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<label asp-for="CheckListHeaderDTO.DocumentNumber"></label>
|
||||
<input asp-for="CheckListHeaderDTO.DocumentNumber" class="form-control" readonly/>
|
||||
<input asp-for="CheckListHeaderDTO.DocumentNumber" class="form-control" readonly />
|
||||
<span asp-validation-for="CheckListHeaderDTO.DocumentNumber" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
@@ -201,8 +208,10 @@
|
||||
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
||||
var formData = getFormAsNestedObject('#CheckListHeaderForm');
|
||||
const $form = $('#CheckListHeaderForm');
|
||||
|
||||
formData.CheckListHeader.RoleDTO=[];
|
||||
|
||||
formData.CheckListHeaderDTO.CheckListRowDTO=[];
|
||||
|
||||
console.log(formData.CheckListHeaderDTO);
|
||||
|
||||
if ($form.valid())
|
||||
{
|
||||
@@ -213,13 +222,24 @@
|
||||
'X-CSRF-TOKEN': csrfToken,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
data: JSON.stringify(formData.CheckListHeader),
|
||||
data: JSON.stringify(formData.CheckListHeaderDTO),
|
||||
success: function (response) {
|
||||
showMessageModal({
|
||||
title: 'Figyelmem!',
|
||||
message: 'Sikeres mentés.',
|
||||
okText: 'Értettem'
|
||||
});
|
||||
if (response.success)
|
||||
{
|
||||
showMessageModal({
|
||||
title: 'Figyelmem!',
|
||||
message: 'Sikeres mentés.',
|
||||
okText: 'Értettem'
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
showMessageModal({
|
||||
title: 'Figyelmem, HIBA!',
|
||||
message: 'Sikertelen mentés.',
|
||||
okText: 'Értettem'
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
// Hiba esetén
|
||||
|
||||
+22
@@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Serilog;
|
||||
using System.Globalization;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.Web.Services.Interfaces;
|
||||
@@ -32,6 +33,27 @@ namespace WorkFlowCheck.Web.Pages.CheckList.CheckListHeader
|
||||
CheckStatus = _checkListService.GetCheckStatus();
|
||||
BuildCheckListHeaderInfo();
|
||||
}
|
||||
public async Task<IActionResult> OnPostSave([FromBody] CheckListHeaderDTO checkListHeaderDTO)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _checkListService.UpdateCheckListHeader(checkListHeaderDTO);
|
||||
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 });
|
||||
}
|
||||
private void BuildCheckListHeaderInfo()
|
||||
{
|
||||
CheckListHeaderInfoDTO = new CheckListHeaderInfoDTO();
|
||||
|
||||
@@ -58,7 +58,34 @@ namespace WorkFlowCheck.Web.Services
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<ApiResponseDTO<CheckListHeaderDTO>> UpdateCheckListHeader(CheckListHeaderDTO checkListHeaderDTO) => throw new NotImplementedException();
|
||||
public async Task<ApiResponseDTO<CheckListHeaderDTO>> UpdateCheckListHeader(CheckListHeaderDTO checkListHeaderDTO)
|
||||
{
|
||||
try
|
||||
{
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/CheckList/UpdateCheckListHeader";
|
||||
|
||||
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, checkListHeaderDTO))
|
||||
{
|
||||
httpResponseMessage.EnsureSuccessStatusCode();
|
||||
|
||||
var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||
var response = JsonConvert.DeserializeObject<ApiResponseDTO<CheckListHeaderDTO>>(jsonString);
|
||||
|
||||
return response ?? new ApiResponseDTO<CheckListHeaderDTO>
|
||||
{
|
||||
IsSuccess = false,
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Hiba visszaadása
|
||||
return new ApiResponseDTO<CheckListHeaderDTO>
|
||||
{
|
||||
IsSuccess = false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ApiResponseDTO<bool>> AcceptCheckListHeader(int id, int userid)
|
||||
{
|
||||
|
||||
@@ -2,13 +2,28 @@
|
||||
// for details on configuring this project to bundle and minify static web assets.
|
||||
|
||||
// Write your JavaScript code.
|
||||
function parseValue(value) {
|
||||
if (value === "") return null;
|
||||
|
||||
// Boolean
|
||||
if (value.toLowerCase() === "true") return true;
|
||||
if (value.toLowerCase() === "false") return false;
|
||||
|
||||
// Number
|
||||
if (!isNaN(value) && value.trim() !== "") return Number(value);
|
||||
|
||||
// ISO dátum formátum felismerése (alap logika)
|
||||
if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(value)) return new Date(value).toISOString();
|
||||
|
||||
return value;
|
||||
}
|
||||
function getFormAsNestedObject(formSelector) {
|
||||
var formArray = $(formSelector).serializeArray();
|
||||
var result = {};
|
||||
|
||||
formArray.forEach(function (item) {
|
||||
var keys = item.name.split('.');
|
||||
var value = item.value;
|
||||
var value = parseValue(item.value);
|
||||
var current = result;
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user