diff --git a/src/WorkFlowCheck.API/Controllers/SyncController.cs b/src/WorkFlowCheck.API/Controllers/SyncController.cs index 1dd7357..57d2f19 100644 --- a/src/WorkFlowCheck.API/Controllers/SyncController.cs +++ b/src/WorkFlowCheck.API/Controllers/SyncController.cs @@ -365,8 +365,8 @@ namespace WorkFlowCheck.API.Controllers return retVal; } - [HttpPost("UpdateCheckListHeader")] - public async Task> UpdateCheckListHeader([FromBody] CheckListHeaderDTO checkListHeaderDTO) + [HttpPost("SendCheckListHeader")] + public async Task> SendCheckListHeader([FromBody] CheckListHeaderDTO checkListHeaderDTO) { var retVal = new ApiResponseDTO() { @@ -375,7 +375,7 @@ namespace WorkFlowCheck.API.Controllers try { - var result = await _syncService.UpdateCheckListHeaderAsync(checkListHeaderDTO); + var result = await _syncService.SendCheckListHeaderAsync(checkListHeaderDTO); retVal.Data = "Sikeres beküldés!"; } diff --git a/src/WorkFlowCheck.BL/Services/Interfaces/ISyncService.cs b/src/WorkFlowCheck.BL/Services/Interfaces/ISyncService.cs index be16adb..4906c49 100644 --- a/src/WorkFlowCheck.BL/Services/Interfaces/ISyncService.cs +++ b/src/WorkFlowCheck.BL/Services/Interfaces/ISyncService.cs @@ -27,7 +27,7 @@ namespace WorkFlowCheck.BL.Services.Interfaces Task> GetAllCheckListTemplateAsync(int userId); Task> GetAllCheckListAsync(int userId); - Task UpdateCheckListHeaderAsync(CheckListHeaderDTO checkListHeaderDTO); + Task SendCheckListHeaderAsync(CheckListHeaderDTO checkListHeaderDTO); Task DeviceMessageSend(DeviceMessageDTO deviceMessageDTO); Task> DeviceMessageReadUnreaded(string deviceId); diff --git a/src/WorkFlowCheck.BL/Services/SyncService.cs b/src/WorkFlowCheck.BL/Services/SyncService.cs index b134d73..edc5b0c 100644 --- a/src/WorkFlowCheck.BL/Services/SyncService.cs +++ b/src/WorkFlowCheck.BL/Services/SyncService.cs @@ -54,8 +54,8 @@ namespace WorkFlowCheck.BL.Services { retVal = _mapper.Map(checkpoint); - var role = await _dbContext.Roles.Where(w => w.Id == retVal.RoleId).FirstOrDefaultAsync(); - + var role = await _dbContext.Roles.Where(w => w.Id == retVal.RoleId).FirstOrDefaultAsync(); + } } catch (Exception ex) @@ -355,24 +355,34 @@ namespace WorkFlowCheck.BL.Services return retVal; } - public async Task UpdateCheckListHeaderAsync(CheckListHeaderDTO checkListHeaderDTO) + public async Task SendCheckListHeaderAsync(CheckListHeaderDTO checkListHeaderDTO) { var retVal = new CheckListHeaderDTO(); try { - if (checkListHeaderDTO.Id == 0) //Hozzáadás, ha Id == 0 - { - - } - else + if (checkListHeaderDTO.Id > 0) //Hozzáadás, ha Id == 0 { + + + var res = await _dbContext.CheckListHeaders .Include(i => i.CheckListRows) .Where(w => w.Id == checkListHeaderDTO.Id) .FirstOrDefaultAsync(); - if (res != null) + if (res != null && (res.CheckStatus == CheckStatus.Open || + res.CheckStatus == CheckStatus.InProgress)) { + if(CanBlock(checkListHeaderDTO)) + { + /// TODO: blokkolás miatt + res.CheckStatus = CheckStatus.Blocked; + await _dbContext.SaveChangesAsync(); + Log.Warning(""); + return retVal; + } + + res.CheckStatus = CheckStatus.InProgress; var ids = checkListHeaderDTO.CheckListRowDTO?.Select(r => r.Id).ToList(); if (ids != null && ids.Count > 0) { @@ -410,7 +420,10 @@ namespace WorkFlowCheck.BL.Services return retVal; } - + private bool CanBlock(CheckListHeaderDTO checkListHeaderDTO) + { + return false; + } public async Task DeviceMessageSend(DeviceMessageDTO deviceMessageDTO) { diff --git a/src/WorkFlowCheck.Common/DTO/CheckListRowDTO.cs b/src/WorkFlowCheck.Common/DTO/CheckListRowDTO.cs index 2779759..129476e 100644 --- a/src/WorkFlowCheck.Common/DTO/CheckListRowDTO.cs +++ b/src/WorkFlowCheck.Common/DTO/CheckListRowDTO.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -13,9 +15,14 @@ namespace WorkFlowCheck.Common.DTO public int CheckListTemplateRowId { get; set; } public CheckListTemplateRowDTO? CheckListTemplateRowDTO { get; set; } public string GroupName => $"AnswerGroup_{CheckListTemplateRowDTO?.RowIndex ?? 0}"; + + [DisplayName("Eredmény")] public string Answer { get; set; } = null!; + public bool? AnswerYes { get; set; } = null!; public bool? AnswerNo { get; set; } = null!; + + [DisplayName("Kép")] public byte[]? Photo { get; set; } = null!; public Guid GuidNumber { get; set; } } diff --git a/src/WorkFlowCheck.Web/Pages/CheckList/CheckListHeader/CheckListHeaderEditPage.cshtml b/src/WorkFlowCheck.Web/Pages/CheckList/CheckListHeader/CheckListHeaderEditPage.cshtml index 1b29190..43cf1fc 100644 --- a/src/WorkFlowCheck.Web/Pages/CheckList/CheckListHeader/CheckListHeaderEditPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/CheckList/CheckListHeader/CheckListHeaderEditPage.cshtml @@ -2,6 +2,8 @@ @model WorkFlowCheck.Web.Pages.CheckList.CheckListHeader.CheckListHeaderEditPageModel @using Microsoft.AspNetCore.Antiforgery @inject IAntiforgery Antiforgery +@using WorkFlowCheck.Common.Helper +@using WorkFlowCheck.Common.DTO @{ ViewData["Title"] = "Ellenőrzés"; var CheckListHeaderId = Model.CheckListHeaderDTO.Id; @@ -59,8 +61,8 @@ ID - Short Name - Checkpoint + @DisplayNameHelper.GetDisplayName(nameof(CheckListRowDTO.CheckListTemplateRowDTO.RowIndex), typeof(CheckListTemplateRowDTO)) + @DisplayNameHelper.GetDisplayName(nameof(CheckListRowDTO.CheckListTemplateRowDTO.CheckPointDTO.ShortName), typeof(CheckPointDTO)) OperationDescription AnswerType Answer diff --git a/src/WorkFlowCheck.Web/wwwroot/js/site.js b/src/WorkFlowCheck.Web/wwwroot/js/site.js index d99e8ec..811da13 100644 --- a/src/WorkFlowCheck.Web/wwwroot/js/site.js +++ b/src/WorkFlowCheck.Web/wwwroot/js/site.js @@ -221,7 +221,7 @@ function renderAnswerType(data) { return data; } function renderAnswerPhoto(data, row) { - if (row.checkListTemplateRowDTO.answerType === 'P') { + if (row.checkListTemplateRowDTO.answerType === 'P' && data.length > 0) { return `
Image
`; } if (row.checkListTemplateRowDTO.answerType === 'SI-N' && data === 'Igen') {