POST hogy tudjunk menteni is.

This commit is contained in:
2025-03-13 14:23:19 +01:00
parent a301a2a168
commit d2106514ba
4 changed files with 69 additions and 9 deletions
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Serilog;
using WorkFlowCheck.BL.Services; using WorkFlowCheck.BL.Services;
using WorkFlowCheck.BL.Services.Interfaces; using WorkFlowCheck.BL.Services.Interfaces;
using WorkFlowCheck.Common.DTO; using WorkFlowCheck.Common.DTO;
@@ -14,7 +15,7 @@ namespace WorkFlowCheck.API.Controllers
{ {
_syncService = syncService; _syncService = syncService;
} }
[HttpGet("GetAllCheckPoints")] [HttpGet("GetAllCheckPoints")]
public async Task<ApiResponseDTO<List<CheckPointDTO>>> GetAllCheckpointsAsync() public async Task<ApiResponseDTO<List<CheckPointDTO>>> GetAllCheckpointsAsync()
{ {
@@ -26,9 +27,9 @@ namespace WorkFlowCheck.API.Controllers
if (checkPointListDTO != null) if (checkPointListDTO != null)
{ {
retVal.IsSuccess = true; retVal.IsSuccess = true;
retVal.Data = checkPointListDTO; retVal.Data = checkPointListDTO;
} }
else else
{ {
@@ -38,7 +39,7 @@ namespace WorkFlowCheck.API.Controllers
return retVal; return retVal;
} }
[HttpGet("GetCheckPoints/{id}")] [HttpGet("GetCheckPoints/{id}")]
public async Task<ApiResponseDTO<CheckPointDTO>> GetAllCheckpointsAsync(int id) public async Task<ApiResponseDTO<CheckPointDTO>> GetAllCheckpointsAsync(int id)
{ {
@@ -134,5 +135,27 @@ namespace WorkFlowCheck.API.Controllers
return retVal; return retVal;
} }
[HttpPost("authenticate")]
public async Task<ApiResponseDTO<CheckPointDTO>> UpdateCheckPoint([FromBody] CheckPointDTO checkPointDTO)
{
var retVal = new ApiResponseDTO<CheckPointDTO>()
{
IsSuccess = true
};
try
{
var result = await _syncService.UpdateCheckPointAsync(checkPointDTO);
retVal.Data = result;
}
catch (Exception ex)
{
retVal.IsSuccess = false;
Log.Error(ex.Message);
}
return retVal;
}
} }
} }
@@ -7,9 +7,10 @@ namespace WorkFlowCheck.BL.Services.Interfaces
{ {
Task<List<CheckPointDTO>> GetAllCheckPointAsync(); Task<List<CheckPointDTO>> GetAllCheckPointAsync();
Task<CheckPointDTO> GetCheckPointAsync(int id); Task<CheckPointDTO> GetCheckPointAsync(int id);
Task<CheckPointDTO> UpdateCheckPointAsync(CheckPointDTO checkPointDTO);
Task<List<LocationDTO>> GetAllLocationAsync(); Task<List<LocationDTO>> GetAllLocationAsync();
Task<List<EquipmentDTO>> GetAllEquipmentAsync(); Task<List<EquipmentDTO>> GetAllEquipmentAsync();
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateAsync(); Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateAsync();
} }
} }
@@ -66,6 +66,30 @@ namespace WorkFlowCheck.BL.Services
return retVal; return retVal;
} }
public async Task<CheckPointDTO> UpdateCheckPointAsync(CheckPointDTO checkPointDTO)
{
var retVal = new CheckPointDTO();
try
{
var res = await _dbContext.CheckPoints.Where(w => w.Id == checkPointDTO.Id).FirstOrDefaultAsync();
if (res != null)
{
res.ShortName = checkPointDTO.ShortName;
res.Code = checkPointDTO.Code;
await _dbContext.SaveChangesAsync();
retVal = _mapper.Map<CheckPointDTO>(res);
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<List<LocationDTO>> GetAllLocationAsync() public async Task<List<LocationDTO>> GetAllLocationAsync()
{ {
var retVal = new List<LocationDTO>(); var retVal = new List<LocationDTO>();
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.RazorPages;
using Serilog;
using WorkFlowCheck.Common.DTO; using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.Web.Services.Interfaces; using WorkFlowCheck.Web.Services.Interfaces;
@@ -31,10 +32,21 @@ namespace WorkFlowCheck.Web.Pages.BaseStock.CheckPoints
CheckPoint = await _baseStockService.GetCheckPoint(id); CheckPoint = await _baseStockService.GetCheckPoint(id);
return new JsonResult(new { data = CheckPoint.CheckListTemplateRowDTO }); return new JsonResult(new { data = CheckPoint.CheckListTemplateRowDTO });
} }
public async Task OnPostSave([FromBody] CheckPointDTO checkPointDTO) public async Task<IActionResult> OnPostSave([FromBody] CheckPointDTO checkPointDTO)
{ {
int i = 0;
try
{
var result = await _baseStockService.UpdateCheckPoint(checkPointDTO);
return new JsonResult(new { success = true });
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return new JsonResult(new { success = false });
} }
} }
} }