From 2e335e7b8abc5c978c3ac9906e0ab7b100e307f4 Mon Sep 17 00:00:00 2001 From: ivanszabo Date: Wed, 19 Mar 2025 18:16:34 +0100 Subject: [PATCH] =?UTF-8?q?CheckListServices=20tov=C3=A1bbfejleszt=C3=A9se?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/CheckListController.cs | 25 +++ .../Mappings/MapperProfile.cs | 12 +- .../Services/CheckListService.cs | 27 +++ .../Services/Interfaces/ICheckListService.cs | 4 + .../DTO/CheckListTemplateRowDTO.cs | 2 + .../CheckPoints/CheckPointEditPage.cshtml | 3 +- .../CheckListTemplateHeaderEditPage.cshtml | 161 ++++++++++++++++++ .../CheckListTemplateHeaderEditPage.cshtml.cs | 22 ++- .../CheckListTemplateHeaderPage.cshtml.cs | 2 +- .../CheckListTemplateRowEditPage.cshtml | 5 +- .../Services/BaseStockService.cs | 2 +- .../Services/CheckListService.cs | 103 +++++++++++ .../Services/Interfaces/CheckListService.cs | 56 ------ .../Services/Interfaces/ICheckListService.cs | 6 +- 14 files changed, 366 insertions(+), 64 deletions(-) create mode 100644 src/WorkFlowCheck.Web/Services/CheckListService.cs delete mode 100644 src/WorkFlowCheck.Web/Services/Interfaces/CheckListService.cs diff --git a/src/WorkFlowCheck.API/Controllers/CheckListController.cs b/src/WorkFlowCheck.API/Controllers/CheckListController.cs index 94ccd43..25ad139 100644 --- a/src/WorkFlowCheck.API/Controllers/CheckListController.cs +++ b/src/WorkFlowCheck.API/Controllers/CheckListController.cs @@ -171,5 +171,30 @@ namespace WorkFlowCheck.API.Controllers } return retVal; } + + + [HttpGet("GetCheckListTemplateRow/{id}")] + public async Task> GetCheckListTemplateRow(int id) + { + var retVal = new ApiResponseDTO() + { + IsSuccess = true, + }; + var checkListTemplateRowDTO = await _checkListService.GetCheckListTemplateRowAsync(id); + + if (checkListTemplateRowDTO != null) + { + + retVal.IsSuccess = true; + retVal.Data = checkListTemplateRowDTO; + } + else + { + retVal.IsSuccess = false; + retVal.Errors.Add("No data!"); + } + + return retVal; + } } } diff --git a/src/WorkFlowCheck.BL/Mappings/MapperProfile.cs b/src/WorkFlowCheck.BL/Mappings/MapperProfile.cs index 9dbae64..ef444a1 100644 --- a/src/WorkFlowCheck.BL/Mappings/MapperProfile.cs +++ b/src/WorkFlowCheck.BL/Mappings/MapperProfile.cs @@ -15,20 +15,30 @@ namespace WorkFlowCheck.BL.Mappings public MapperProfile() { CreateMap().ForMember(dest => dest.RoleDTO, opt => opt.MapFrom(src => src.UserRoles.Select(ur => ur.Role))); + CreateMap(); + CreateMap() .ForMember(dest => dest.RoleDTO, opt => opt.MapFrom(src => src.Role)) .ForMember(dest => dest.UserDTO, opt => opt.MapFrom(src => src.User)); + CreateMap() .ForMember(dest => dest.PasswordHash, opt => opt.MapFrom()); CreateMap() .ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRows)); - CreateMap(); + + CreateMap() + .ForMember(dest => dest.EquipmentDTO, opt => opt.MapFrom(src => src.Equipment)) + .ForMember(dest => dest.CheckPointDTO, opt => opt.MapFrom(src => src.CheckPoint)); + CreateMap().ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRows)); + CreateMap(); + CreateMap(); + CreateMap(); CreateMap() diff --git a/src/WorkFlowCheck.BL/Services/CheckListService.cs b/src/WorkFlowCheck.BL/Services/CheckListService.cs index 69a582a..4e860ad 100644 --- a/src/WorkFlowCheck.BL/Services/CheckListService.cs +++ b/src/WorkFlowCheck.BL/Services/CheckListService.cs @@ -237,5 +237,32 @@ namespace WorkFlowCheck.BL.Services return retVal; } + + public async Task GetCheckListTemplateRowAsync(int id) + { + var retVal = new CheckListTemplateRowDTO(); + try + { + var res = await _dbContext.CheckListTemplateRows + .Include(i=> i.Equipment) + .Include(i=> i.CheckPoint) + .Where(w => w.Id == id) + .AsNoTracking() + .FirstOrDefaultAsync(); + + if (res != null) + { + retVal = _mapper.Map(res); + + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + + return retVal; + } + public Task UpdateCheckListTemplateRowAsync(CheckListTemplateRowDTO checkListTemplateRowDTO) => throw new NotImplementedException(); } } diff --git a/src/WorkFlowCheck.BL/Services/Interfaces/ICheckListService.cs b/src/WorkFlowCheck.BL/Services/Interfaces/ICheckListService.cs index c29ef8b..0aa13eb 100644 --- a/src/WorkFlowCheck.BL/Services/Interfaces/ICheckListService.cs +++ b/src/WorkFlowCheck.BL/Services/Interfaces/ICheckListService.cs @@ -19,5 +19,9 @@ namespace WorkFlowCheck.BL.Services.Interfaces Task GetCheckListTemplateHeaderAsync(int Id); Task> GetAllCheckListTemplateHeaderAsync(); Task UpdateCheckListTemplateHeaderAsync(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO); + + Task GetCheckListTemplateRowAsync(int id); + Task UpdateCheckListTemplateRowAsync(CheckListTemplateRowDTO checkListTemplateRowDTO); + } } diff --git a/src/WorkFlowCheck.Common/DTO/CheckListTemplateRowDTO.cs b/src/WorkFlowCheck.Common/DTO/CheckListTemplateRowDTO.cs index f954378..48acd2b 100644 --- a/src/WorkFlowCheck.Common/DTO/CheckListTemplateRowDTO.cs +++ b/src/WorkFlowCheck.Common/DTO/CheckListTemplateRowDTO.cs @@ -9,8 +9,10 @@ namespace WorkFlowCheck.Common.DTO public int CheckListTemplateHeaderId { get; set; } public int EquipmentId { get; set; } + public EquipmentDTO EquipmentDTO { get; set; } public int CheckPointId { get; set; } + public CheckPointDTO CheckPointDTO { get; set; } public string OperationDescription { get; set; } = null!; diff --git a/src/WorkFlowCheck.Web/Pages/BaseStock/CheckPoints/CheckPointEditPage.cshtml b/src/WorkFlowCheck.Web/Pages/BaseStock/CheckPoints/CheckPointEditPage.cshtml index deb2a21..f82fae9 100644 --- a/src/WorkFlowCheck.Web/Pages/BaseStock/CheckPoints/CheckPointEditPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/BaseStock/CheckPoints/CheckPointEditPage.cshtml @@ -29,6 +29,7 @@
+
@@ -98,7 +99,7 @@ $('#tbCheckPointsEditPage').on('click', '.edit-btn', function () { const row = table.row($(this).closest('tr')).data(); - window.location.href = `@Url.Page("./CheckListTemplateRowEditPage")?id=${row.id}`; + window.location.href = `@Url.Page("/CheckListTemplate/CheckListTemplateRows/CheckListTemplateRowEditPage")?id=${row.id}`; }); $('#tbCheckPointsEditPage').on('click', '.delete-btn', function () diff --git a/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderEditPage.cshtml b/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderEditPage.cshtml index 835579d..7e3387d 100644 --- a/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderEditPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderEditPage.cshtml @@ -1,4 +1,165 @@ @page @model WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader.CheckListTemplateHeaderEditPageModel +@using Microsoft.AspNetCore.Antiforgery +@inject IAntiforgery Antiforgery @{ + ViewData["Title"] = "Ellenőrzés sablon"; + var CheckListTemplateHeaderId = Model.CheckListTemplateHeaderDTO.Id; + var url = Url.Page("./CheckListTemplateHeaderEditPage", "LoadCheckListTemplateRows", new { id = CheckListTemplateHeaderId }); + var urlPost = Url.Page("./CheckListTemplateHeaderEditPage", "Save"); +} +

@ViewData["Title"]

+ + + + +
+
+ + +
+ + + +
+
+ + +
+
+
+

+
+ + + + + + + + + + + + + + + + + + + +
IDShort NameOperationDescriptionAnswerTypeAction
IDShort NameOperationDescriptionAnswerTypeAction
+
+@section Scripts { + } diff --git a/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderEditPage.cshtml.cs b/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderEditPage.cshtml.cs index fb1754f..b1e6c9f 100644 --- a/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderEditPage.cshtml.cs +++ b/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderEditPage.cshtml.cs @@ -1,12 +1,32 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; +using WorkFlowCheck.Common.DTO; +using WorkFlowCheck.Web.Services.Interfaces; namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader { public class CheckListTemplateHeaderEditPageModel : PageModel { - public void OnGet() + private readonly ILogger _logger; + private readonly ICheckListService _checkListService; + + [BindProperty] + public CheckListTemplateHeaderDTO CheckListTemplateHeaderDTO { get; set; } + + + public CheckListTemplateHeaderEditPageModel(ILogger logger, ICheckListService checkListService) { + _logger = logger; + _checkListService = checkListService; + } + public async Task OnGet(int id) + { + CheckListTemplateHeaderDTO = await _checkListService.GetCheckListTemplateHeader(id); + } + public async Task OnGetLoadCheckListTemplateRows(int id) + { + CheckListTemplateHeaderDTO = await _checkListService.GetCheckListTemplateHeader(id); + return new JsonResult(new { data = CheckListTemplateHeaderDTO.CheckListTemplateRowDTO }); } } } diff --git a/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderPage.cshtml.cs b/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderPage.cshtml.cs index 15fb42e..19ef305 100644 --- a/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderPage.cshtml.cs +++ b/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateHeader/CheckListTemplateHeaderPage.cshtml.cs @@ -18,7 +18,7 @@ namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateHeader } public async Task OnGetLoadCheckListTemplateHeaders() { - var results = await _checkListService.GetAllCheckListHeaderAsync(); + var results = await _checkListService.GetAllCheckListTemplateHeaderAsync(); return new JsonResult(new { data = results }); } } diff --git a/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateRows/CheckListTemplateRowEditPage.cshtml b/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateRows/CheckListTemplateRowEditPage.cshtml index 6279819..8064717 100644 --- a/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateRows/CheckListTemplateRowEditPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/CheckListTemplate/CheckListTemplateRows/CheckListTemplateRowEditPage.cshtml @@ -1,4 +1,4 @@ -@page +@page @model WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateRows.CheckListTemplateRowEditPageModel @using Microsoft.AspNetCore.Antiforgery @inject IAntiforgery Antiforgery @@ -20,7 +20,7 @@
- +
@@ -31,6 +31,7 @@
+
diff --git a/src/WorkFlowCheck.Web/Services/BaseStockService.cs b/src/WorkFlowCheck.Web/Services/BaseStockService.cs index 9a97623..c052e72 100644 --- a/src/WorkFlowCheck.Web/Services/BaseStockService.cs +++ b/src/WorkFlowCheck.Web/Services/BaseStockService.cs @@ -144,7 +144,7 @@ namespace WorkFlowCheck.Web.Services public async Task GetCheckListTemplateRow(int id) { - string endpoint = $"{_httpClient.BaseAddress}api/Sync/GetCheckListTemplateRow/{id}"; + string endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetCheckListTemplateRow/{id}"; var retVal = new CheckListTemplateRowDTO(); try { diff --git a/src/WorkFlowCheck.Web/Services/CheckListService.cs b/src/WorkFlowCheck.Web/Services/CheckListService.cs new file mode 100644 index 0000000..30e2c6b --- /dev/null +++ b/src/WorkFlowCheck.Web/Services/CheckListService.cs @@ -0,0 +1,103 @@ +using Serilog; +using System.Net.Http; +using WorkFlowCheck.Common.DTO; +using WorkFlowCheck.Web.Services.Interfaces; + +namespace WorkFlowCheck.Web.Services +{ + public class CheckListService : BaseService, ICheckListService + { + public CheckListService(HttpClient httpClient, IConfiguration configuration, IHttpContextAccessor httpContextAccessor) : base(httpClient, configuration, httpContextAccessor) + { + } + + public async Task> GetAllCheckListHeaderAsync() + { + var endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetAllCheckListHeaders"; + var retVal = new List(); + try + { + var response = await _httpClient.GetFromJsonAsync>>(endpoint); + if (response != null) + { + if (response.IsSuccess) + { + return response.Data; + } + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + return retVal; + } + public async Task GetCheckListHeader(int id) + { + var endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetCheckListHeader/{id}"; + var retVal = new CheckListHeaderDTO() { CheckListRowDTO = new List() }; + try + { + var response = await _httpClient.GetFromJsonAsync>(endpoint); + if (response != null) + { + if (response.IsSuccess) + { + return response.Data; + } + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + return retVal; + } + public async Task> UpdateCheckListHeader(CheckListHeaderDTO checkListHeaderDTO) => throw new NotImplementedException(); + + + public async Task> GetAllCheckListTemplateHeaderAsync() + { + var endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetAllCheckListTemplateHeaders"; + var retVal = new List(); + try + { + var response = await _httpClient.GetFromJsonAsync>>(endpoint); + if (response != null) + { + if (response.IsSuccess) + { + return response.Data; + } + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + return retVal; + } + public async Task GetCheckListTemplateHeader(int id) + { + var endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetCheckListTemplateHeader/{id}"; + var retVal = new CheckListTemplateHeaderDTO() { CheckListTemplateRowDTO = new List() }; + try + { + var response = await _httpClient.GetFromJsonAsync>(endpoint); + if (response != null) + { + if (response.IsSuccess) + { + return response.Data; + } + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + return retVal; + } + public async Task> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO) => throw new NotImplementedException(); + } +} diff --git a/src/WorkFlowCheck.Web/Services/Interfaces/CheckListService.cs b/src/WorkFlowCheck.Web/Services/Interfaces/CheckListService.cs deleted file mode 100644 index a7ab213..0000000 --- a/src/WorkFlowCheck.Web/Services/Interfaces/CheckListService.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Serilog; -using System.Net.Http; -using WorkFlowCheck.Common.DTO; - -namespace WorkFlowCheck.Web.Services.Interfaces -{ - public class CheckListService : BaseService, ICheckListService - { - public CheckListService(HttpClient httpClient, IConfiguration configuration, IHttpContextAccessor httpContextAccessor) : base(httpClient, configuration, httpContextAccessor) - { - } - public async Task> GetAllCheckListHeaderAsync() - { - string endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetAllCheckListHeaders"; - var retVal = new List(); - try - { - var response = await _httpClient.GetFromJsonAsync>>(endpoint); - if (response != null) - { - if (response.IsSuccess) - { - return response.Data; - } - } - } - catch (Exception ex) - { - Log.Error(ex.Message); - } - return retVal; - } - public async Task GetCheckListHeader(int id) - { - string endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetCheckListHeader/{id}"; - var retVal = new CheckListHeaderDTO() { CheckListRowDTO = new List() }; - try - { - var response = await _httpClient.GetFromJsonAsync>(endpoint); - if (response != null) - { - if (response.IsSuccess) - { - return response.Data; - } - } - } - catch (Exception ex) - { - Log.Error(ex.Message); - } - return retVal; - } - public async Task> UpdateCheckListHeader(CheckListHeaderDTO checkListHeaderDTO) => throw new NotImplementedException(); - } -} diff --git a/src/WorkFlowCheck.Web/Services/Interfaces/ICheckListService.cs b/src/WorkFlowCheck.Web/Services/Interfaces/ICheckListService.cs index f9f7808..2504e75 100644 --- a/src/WorkFlowCheck.Web/Services/Interfaces/ICheckListService.cs +++ b/src/WorkFlowCheck.Web/Services/Interfaces/ICheckListService.cs @@ -7,6 +7,10 @@ namespace WorkFlowCheck.Web.Services.Interfaces Task GetCheckListHeader(int id); Task> GetAllCheckListHeaderAsync(); Task> UpdateCheckListHeader(CheckListHeaderDTO checkListHeaderDTO); - + + Task GetCheckListTemplateHeader(int id); + Task> GetAllCheckListTemplateHeaderAsync(); + Task> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO); + } }