Equipment is kész.
This commit is contained in:
@@ -196,5 +196,26 @@ namespace WorkFlowCheck.API.Controllers
|
|||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
[HttpPost("UpdateCheckListTemplateRow")]
|
||||||
|
public async Task<ApiResponseDTO<CheckListTemplateRowDTO>> UpdateCheckListTemplateRow([FromBody] CheckListTemplateRowDTO CheckListTemplateRowDTO)
|
||||||
|
{
|
||||||
|
var retVal = new ApiResponseDTO<CheckListTemplateRowDTO>()
|
||||||
|
{
|
||||||
|
IsSuccess = true
|
||||||
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await _checkListService.UpdateCheckListTemplateRowAsync(CheckListTemplateRowDTO);
|
||||||
|
retVal.Data = result;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
retVal.IsSuccess = false;
|
||||||
|
Log.Error(ex.Message);
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,31 @@ namespace WorkFlowCheck.API.Controllers
|
|||||||
_syncService = syncService;
|
_syncService = syncService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet("GetCheckPoint/{id}")]
|
||||||
|
public async Task<ApiResponseDTO<CheckPointDTO>> GetCheckpointAsync(int id)
|
||||||
|
{
|
||||||
|
var retVal = new ApiResponseDTO<CheckPointDTO>()
|
||||||
|
{
|
||||||
|
IsSuccess = true,
|
||||||
|
};
|
||||||
|
var checkPointListDTO = await _syncService.GetCheckPointAsync(id);
|
||||||
|
|
||||||
|
if (checkPointListDTO != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
retVal.IsSuccess = true;
|
||||||
|
retVal.Data = checkPointListDTO;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retVal.IsSuccess = false;
|
||||||
|
retVal.Errors.Add("No data!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
[HttpGet("GetAllCheckPoints")]
|
[HttpGet("GetAllCheckPoints")]
|
||||||
public async Task<ApiResponseDTO<List<CheckPointDTO>>> GetAllCheckpointsAsync()
|
public async Task<ApiResponseDTO<List<CheckPointDTO>>> GetAllCheckpointsAsync()
|
||||||
{
|
{
|
||||||
@@ -39,9 +64,31 @@ namespace WorkFlowCheck.API.Controllers
|
|||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
[HttpPost("UpdateCheckPoint")]
|
||||||
|
public async Task<ApiResponseDTO<CheckPointDTO>> UpdateCheckPoint([FromBody] CheckPointDTO checkPointDTO)
|
||||||
|
{
|
||||||
|
var retVal = new ApiResponseDTO<CheckPointDTO>()
|
||||||
|
{
|
||||||
|
IsSuccess = true
|
||||||
|
};
|
||||||
|
|
||||||
[HttpGet("GetCheckPoints/{id}")]
|
try
|
||||||
public async Task<ApiResponseDTO<CheckPointDTO>> GetCheckpointsAsync(int id)
|
{
|
||||||
|
var result = await _syncService.UpdateCheckPointAsync(checkPointDTO);
|
||||||
|
retVal.Data = result;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
retVal.IsSuccess = false;
|
||||||
|
Log.Error(ex.Message);
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet("GetEquipment/{id}")]
|
||||||
|
public async Task<ApiResponseDTO<CheckPointDTO>> GetEquipmentAsync(int id)
|
||||||
{
|
{
|
||||||
var retVal = new ApiResponseDTO<CheckPointDTO>()
|
var retVal = new ApiResponseDTO<CheckPointDTO>()
|
||||||
{
|
{
|
||||||
@@ -63,7 +110,6 @@ namespace WorkFlowCheck.API.Controllers
|
|||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("GetAllEquipments")]
|
[HttpGet("GetAllEquipments")]
|
||||||
public async Task<ApiResponseDTO<List<EquipmentDTO>>> GetAllEquipmentsAsync()
|
public async Task<ApiResponseDTO<List<EquipmentDTO>>> GetAllEquipmentsAsync()
|
||||||
{
|
{
|
||||||
@@ -87,7 +133,52 @@ namespace WorkFlowCheck.API.Controllers
|
|||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
[HttpPost("UpdateEquipment")]
|
||||||
|
public async Task<ApiResponseDTO<EquipmentDTO>> UpdateEquipment([FromBody] EquipmentDTO EquipmentDTO)
|
||||||
|
{
|
||||||
|
var retVal = new ApiResponseDTO<EquipmentDTO>()
|
||||||
|
{
|
||||||
|
IsSuccess = true
|
||||||
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await _syncService.UpdateEquipmentAsync(EquipmentDTO);
|
||||||
|
retVal.Data = result;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
retVal.IsSuccess = false;
|
||||||
|
Log.Error(ex.Message);
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet("GetLocation/{id}")]
|
||||||
|
public async Task<ApiResponseDTO<CheckPointDTO>> GetLocationAsync(int id)
|
||||||
|
{
|
||||||
|
var retVal = new ApiResponseDTO<CheckPointDTO>()
|
||||||
|
{
|
||||||
|
IsSuccess = true,
|
||||||
|
};
|
||||||
|
var checkPointListDTO = await _syncService.GetCheckPointAsync(id);
|
||||||
|
|
||||||
|
if (checkPointListDTO != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
retVal.IsSuccess = true;
|
||||||
|
retVal.Data = checkPointListDTO;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retVal.IsSuccess = false;
|
||||||
|
retVal.Errors.Add("No data!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
[HttpGet("GetAllLocations")]
|
[HttpGet("GetAllLocations")]
|
||||||
public async Task<ApiResponseDTO<List<LocationDTO>>> GetAllLocationsAsync()
|
public async Task<ApiResponseDTO<List<LocationDTO>>> GetAllLocationsAsync()
|
||||||
{
|
{
|
||||||
@@ -111,6 +202,28 @@ namespace WorkFlowCheck.API.Controllers
|
|||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
[HttpPost("UpdateLocation")]
|
||||||
|
public async Task<ApiResponseDTO<LocationDTO>> UpdateLocation([FromBody] LocationDTO LocationDTO)
|
||||||
|
{
|
||||||
|
var retVal = new ApiResponseDTO<LocationDTO>()
|
||||||
|
{
|
||||||
|
IsSuccess = true
|
||||||
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await _syncService.UpdateLocationAsync(LocationDTO);
|
||||||
|
retVal.Data = result;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
retVal.IsSuccess = false;
|
||||||
|
Log.Error(ex.Message);
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpGet("GetAllCheckListTemplateHeader")]
|
[HttpGet("GetAllCheckListTemplateHeader")]
|
||||||
public async Task<ApiResponseDTO<List<CheckListTemplateHeaderDTO>>> GetAllCheckListTemplateHeaderAsync()
|
public async Task<ApiResponseDTO<List<CheckListTemplateHeaderDTO>>> GetAllCheckListTemplateHeaderAsync()
|
||||||
@@ -136,26 +249,10 @@ namespace WorkFlowCheck.API.Controllers
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("UpdateCheckPoint")]
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,9 +38,11 @@ namespace WorkFlowCheck.BL.Mappings
|
|||||||
CreateMap<CheckPointDTO, CheckPoint>();
|
CreateMap<CheckPointDTO, CheckPoint>();
|
||||||
|
|
||||||
CreateMap<Location, LocationDTO>();
|
CreateMap<Location, LocationDTO>();
|
||||||
|
CreateMap<LocationDTO, Location>();
|
||||||
|
|
||||||
CreateMap<Equipment, EquipmentDTO>();
|
CreateMap<Equipment, EquipmentDTO>();
|
||||||
|
CreateMap<EquipmentDTO, Equipment>();
|
||||||
|
|
||||||
CreateMap<CheckListHeader, CheckListHeaderDTO>()
|
CreateMap<CheckListHeader, CheckListHeaderDTO>()
|
||||||
.ForMember(dest => dest.CheckListRowDTO, opt => opt.MapFrom(src => src.CheckListRows));
|
.ForMember(dest => dest.CheckListRowDTO, opt => opt.MapFrom(src => src.CheckListRows));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ namespace WorkFlowCheck.BL.Services
|
|||||||
var res = await _dbContext.CheckListTemplateHeaders
|
var res = await _dbContext.CheckListTemplateHeaders
|
||||||
.Where(w => w.Id == Id)
|
.Where(w => w.Id == Id)
|
||||||
.Include(i => i.CheckListTemplateRows)
|
.Include(i => i.CheckListTemplateRows)
|
||||||
.ThenInclude(i=> i.CheckPoint)
|
.ThenInclude(i => i.CheckPoint)
|
||||||
.Include(i => i.CheckListTemplateRows)
|
.Include(i => i.CheckListTemplateRows)
|
||||||
.ThenInclude(i => i.Equipment)
|
.ThenInclude(i => i.Equipment)
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
@@ -210,7 +210,7 @@ namespace WorkFlowCheck.BL.Services
|
|||||||
{
|
{
|
||||||
Description = checkListTemplateHeaderDTO.Description,
|
Description = checkListTemplateHeaderDTO.Description,
|
||||||
ShortName = checkListTemplateHeaderDTO.ShortName,
|
ShortName = checkListTemplateHeaderDTO.ShortName,
|
||||||
IsDeleted =false,
|
IsDeleted = false,
|
||||||
|
|
||||||
};
|
};
|
||||||
_dbContext.CheckListTemplateHeaders.Add(checkListTemplateHeader);
|
_dbContext.CheckListTemplateHeaders.Add(checkListTemplateHeader);
|
||||||
@@ -226,7 +226,7 @@ namespace WorkFlowCheck.BL.Services
|
|||||||
if (checkListTemplateHeader != null)
|
if (checkListTemplateHeader != null)
|
||||||
{
|
{
|
||||||
checkListTemplateHeader.Description = checkListTemplateHeaderDTO.Description;
|
checkListTemplateHeader.Description = checkListTemplateHeaderDTO.Description;
|
||||||
checkListTemplateHeader.ShortName = checkListTemplateHeaderDTO.ShortName;
|
checkListTemplateHeader.ShortName = checkListTemplateHeaderDTO.ShortName;
|
||||||
|
|
||||||
await _dbContext.SaveChangesAsync();
|
await _dbContext.SaveChangesAsync();
|
||||||
retVal = _mapper.Map<CheckListTemplateHeaderDTO>(checkListTemplateHeader);
|
retVal = _mapper.Map<CheckListTemplateHeaderDTO>(checkListTemplateHeader);
|
||||||
@@ -247,8 +247,8 @@ namespace WorkFlowCheck.BL.Services
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var res = await _dbContext.CheckListTemplateRows
|
var res = await _dbContext.CheckListTemplateRows
|
||||||
.Include(i=> i.Equipment)
|
.Include(i => i.Equipment)
|
||||||
.Include(i=> i.CheckPoint)
|
.Include(i => i.CheckPoint)
|
||||||
.Where(w => w.Id == id)
|
.Where(w => w.Id == id)
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
@@ -266,6 +266,52 @@ namespace WorkFlowCheck.BL.Services
|
|||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
public Task<CheckListTemplateRowDTO> UpdateCheckListTemplateRowAsync(CheckListTemplateRowDTO checkListTemplateRowDTO) => throw new NotImplementedException();
|
public async Task<CheckListTemplateRowDTO> UpdateCheckListTemplateRowAsync(CheckListTemplateRowDTO checkListTemplateRowDTO)
|
||||||
|
{
|
||||||
|
var retVal = new CheckListTemplateRowDTO() { };
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (checkListTemplateRowDTO.Id == 0)
|
||||||
|
{
|
||||||
|
var checkListTemplateRow = new CheckListTemplateRow()
|
||||||
|
{
|
||||||
|
CheckListTemplateHeaderId = checkListTemplateRowDTO.CheckListTemplateHeaderId,
|
||||||
|
CheckPointId = checkListTemplateRowDTO.CheckPointId,
|
||||||
|
EquipmentId = checkListTemplateRowDTO.EquipmentId,
|
||||||
|
OperationDescription = checkListTemplateRowDTO.OperationDescription,
|
||||||
|
AnswerType = checkListTemplateRowDTO.AnswerType,
|
||||||
|
RowIndex = checkListTemplateRowDTO.RowIndex,
|
||||||
|
|
||||||
|
};
|
||||||
|
_dbContext.CheckListTemplateRows.Add(checkListTemplateRow);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
retVal = _mapper.Map<CheckListTemplateRowDTO>(checkListTemplateRow);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var checkListTemplateRow = await _dbContext.CheckListTemplateRows
|
||||||
|
.Where(w => w.Id == checkListTemplateRowDTO.Id)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (checkListTemplateRow != null)
|
||||||
|
{
|
||||||
|
checkListTemplateRow.CheckListTemplateHeaderId = checkListTemplateRowDTO.CheckListTemplateHeaderId;
|
||||||
|
checkListTemplateRow.CheckPointId = checkListTemplateRowDTO.CheckPointId;
|
||||||
|
checkListTemplateRow.EquipmentId = checkListTemplateRowDTO.EquipmentId;
|
||||||
|
checkListTemplateRow.OperationDescription = checkListTemplateRowDTO.OperationDescription;
|
||||||
|
checkListTemplateRow.AnswerType = checkListTemplateRowDTO.AnswerType;
|
||||||
|
checkListTemplateRow.RowIndex = checkListTemplateRowDTO.RowIndex;
|
||||||
|
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
retVal = _mapper.Map<CheckListTemplateRowDTO>(checkListTemplateRow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,17 @@ 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<CheckPointDTO> UpdateCheckPointAsync(CheckPointDTO checkPointDTO);
|
||||||
|
|
||||||
|
|
||||||
Task<List<LocationDTO>> GetAllLocationAsync();
|
Task<List<LocationDTO>> GetAllLocationAsync();
|
||||||
|
Task<LocationDTO> GetLocationAsync(int id);
|
||||||
|
Task<LocationDTO> UpdateLocationAsync(LocationDTO LocationDTO);
|
||||||
|
|
||||||
|
|
||||||
Task<List<EquipmentDTO>> GetAllEquipmentAsync();
|
Task<List<EquipmentDTO>> GetAllEquipmentAsync();
|
||||||
|
Task<EquipmentDTO> GetEquipmentAsync(int id);
|
||||||
|
Task<EquipmentDTO> UpdateEquipmentAsync(EquipmentDTO EquipmentDTO);
|
||||||
|
|
||||||
|
|
||||||
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateAsync();
|
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateAsync();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,6 +101,9 @@ namespace WorkFlowCheck.BL.Services
|
|||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public async Task<List<LocationDTO>> GetAllLocationAsync()
|
public async Task<List<LocationDTO>> GetAllLocationAsync()
|
||||||
{
|
{
|
||||||
var retVal = new List<LocationDTO>();
|
var retVal = new List<LocationDTO>();
|
||||||
@@ -120,6 +123,67 @@ namespace WorkFlowCheck.BL.Services
|
|||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
public async Task<LocationDTO> GetLocationAsync(int id)
|
||||||
|
{
|
||||||
|
var retVal = new LocationDTO();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var res = await _dbContext.Locations
|
||||||
|
.Where(w => w.Id == id)
|
||||||
|
.AsNoTracking()
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
retVal = _mapper.Map<LocationDTO>(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
public async Task<LocationDTO> UpdateLocationAsync(LocationDTO LocationDTO)
|
||||||
|
{
|
||||||
|
var retVal = new LocationDTO();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (LocationDTO.Id == 0) //Hozzáadás, ha Id == 0
|
||||||
|
{
|
||||||
|
var Location = _mapper.Map<Location>(LocationDTO);
|
||||||
|
_dbContext.Locations.Add(Location);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
retVal = _mapper.Map<LocationDTO>(Location);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var res = await _dbContext.Locations.Where(w => w.Id == LocationDTO.Id).FirstOrDefaultAsync();
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
res=_mapper.Map<Location>(LocationDTO);
|
||||||
|
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
retVal = _mapper.Map<LocationDTO>(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public async Task<List<EquipmentDTO>> GetAllEquipmentAsync()
|
public async Task<List<EquipmentDTO>> GetAllEquipmentAsync()
|
||||||
{
|
{
|
||||||
var retVal = new List<EquipmentDTO>();
|
var retVal = new List<EquipmentDTO>();
|
||||||
@@ -139,6 +203,63 @@ namespace WorkFlowCheck.BL.Services
|
|||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
public async Task<EquipmentDTO> GetEquipmentAsync(int id)
|
||||||
|
{
|
||||||
|
var retVal = new EquipmentDTO();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var res = await _dbContext.Equipments
|
||||||
|
.Where(w => w.Id == id)
|
||||||
|
.AsNoTracking()
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
retVal = _mapper.Map<EquipmentDTO>(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
public async Task<EquipmentDTO> UpdateEquipmentAsync(EquipmentDTO EquipmentDTO)
|
||||||
|
{
|
||||||
|
var retVal = new EquipmentDTO();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (EquipmentDTO.Id == 0) //Hozzáadás, ha Id == 0
|
||||||
|
{
|
||||||
|
var Equipment = _mapper.Map<Equipment>(EquipmentDTO);
|
||||||
|
_dbContext.Equipments.Add(Equipment);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
retVal = _mapper.Map<EquipmentDTO>(Equipment);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var res = await _dbContext.Equipments.Where(w => w.Id == EquipmentDTO.Id).FirstOrDefaultAsync();
|
||||||
|
if (res != null)
|
||||||
|
{
|
||||||
|
res.ShortName = EquipmentDTO.ShortName;
|
||||||
|
res.EquipmentNumber = EquipmentDTO.EquipmentNumber;
|
||||||
|
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
retVal = _mapper.Map<EquipmentDTO>(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
public async Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateAsync()
|
public async Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateAsync()
|
||||||
{
|
{
|
||||||
var retVal = new List<CheckListTemplateHeaderDTO>();
|
var retVal = new List<CheckListTemplateHeaderDTO>();
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ namespace WorkFlowCheck.Common.DTO
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int RowIndex { get; set; }
|
public int RowIndex { get; set; }
|
||||||
public int CheckListTemplateHeaderId { get; set; }
|
public int CheckListTemplateHeaderId { get; set; }
|
||||||
|
|
||||||
public int EquipmentId { get; set; }
|
public int EquipmentId { get; set; }
|
||||||
public EquipmentDTO EquipmentDTO { get; set; }
|
public EquipmentDTO? EquipmentDTO { get; set; } = null!;
|
||||||
|
|
||||||
public int CheckPointId { get; set; }
|
public int CheckPointId { get; set; }
|
||||||
public CheckPointDTO CheckPointDTO { get; set; }
|
public CheckPointDTO? CheckPointDTO { get; set; } = null!;
|
||||||
|
|
||||||
public string OperationDescription { get; set; } = null!;
|
public string OperationDescription { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -29,6 +29,6 @@ namespace WorkFlowCheck.Common.DTO
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string AnswerType { get; set; } = null!;
|
public string AnswerType { get; set; } = null!;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,14 @@ namespace WorkFlowCheck.Web.Middleware
|
|||||||
{
|
{
|
||||||
context.User = new ClaimsPrincipal(new ClaimsIdentity(claims, "jwt"));
|
context.User = new ClaimsPrincipal(new ClaimsIdentity(claims, "jwt"));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Ha token van, de invalid, töröljük a cookiet
|
||||||
|
if (!string.IsNullOrEmpty(token))
|
||||||
|
{
|
||||||
|
context.Response.Cookies.Delete("AuthToken");
|
||||||
|
}
|
||||||
|
}
|
||||||
await _next(context);
|
await _next(context);
|
||||||
}
|
}
|
||||||
private bool ValidateToken(string token, out Claim[] claims)
|
private bool ValidateToken(string token, out Claim[] claims)
|
||||||
|
|||||||
@@ -1,4 +1,96 @@
|
|||||||
@page
|
@page
|
||||||
@model WorkFlowCheck.Web.Pages.BaseStock.Equipments.EquipmentEditPageModel
|
@model WorkFlowCheck.Web.Pages.BaseStock.Equipments.EquipmentEditPageModel
|
||||||
|
@using Microsoft.AspNetCore.Antiforgery
|
||||||
|
@inject IAntiforgery Antiforgery
|
||||||
@{
|
@{
|
||||||
|
ViewData["Title"] = "Berendezés";
|
||||||
|
var EquipmentId = Model.EquipmentDTO.Id;
|
||||||
|
var urlPost = Url.Page("./EquipmentEditPage", "Save");
|
||||||
}
|
}
|
||||||
|
<h1>@ViewData["Title"]</h1>
|
||||||
|
|
||||||
|
<input type="hidden" id="EquipmentEditPostUrl" value="@urlPost" />
|
||||||
|
|
||||||
|
<div class="card shadow p-4">
|
||||||
|
<form method="post" id="EquipmentForm">
|
||||||
|
<meta name="csrf-token" content="@Antiforgery.GetAndStoreTokens(HttpContext).RequestToken" />
|
||||||
|
<input type="hidden" asp-for="EquipmentDTO.Id" />
|
||||||
|
<div class="mb-3">
|
||||||
|
<label asp-for="EquipmentDTO.ShortName"></label>
|
||||||
|
<input asp-for="EquipmentDTO.ShortName" class="form-control" />
|
||||||
|
<span asp-validation-for="EquipmentDTO.ShortName" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label asp-for="EquipmentDTO.EquipmentNumber"></label>
|
||||||
|
<input asp-for="EquipmentDTO.EquipmentNumber" class="form-control" />
|
||||||
|
<span asp-validation-for="EquipmentDTO.EquipmentNumber" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3 d-flex justify-content-between">
|
||||||
|
<button type="button" id="saveEquipment" class="btn btn-primary">Mentés</button>
|
||||||
|
<button type="button" class="btn btn-secondary" onclick="history.back()">Mégsem</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@section Scripts {
|
||||||
|
<script>
|
||||||
|
|
||||||
|
$("#saveEquipment").click(function () {
|
||||||
|
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
||||||
|
var formData = getFormAsNestedObject('#EquipmentForm');
|
||||||
|
const $form = $('#EquipmentForm');
|
||||||
|
|
||||||
|
console.log(formData.Equipment);
|
||||||
|
|
||||||
|
if ($form.valid())
|
||||||
|
{
|
||||||
|
$.ajax({
|
||||||
|
url: $('#EquipmentEditPostUrl').val(),
|
||||||
|
type: 'POST',
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-TOKEN': csrfToken,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
data: JSON.stringify(formData.EquipmentDTO),
|
||||||
|
success: function (response) {
|
||||||
|
showMessageModal({
|
||||||
|
title: 'Figyelmem!',
|
||||||
|
message: 'Sikeres mentés.',
|
||||||
|
okText: 'Értettem'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
// Hiba esetén
|
||||||
|
console.error("Hiba: ", error);
|
||||||
|
showMessageModal({
|
||||||
|
title: 'Hiba!',
|
||||||
|
message: 'A mentés NEM sikerült!',
|
||||||
|
okText: 'Értettem'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
$form[0].reportValidity();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
const $form = $("#EquipmentForm");
|
||||||
|
|
||||||
|
$form.validate({
|
||||||
|
errorClass: "text-danger small",
|
||||||
|
errorPlacement: function (error, element) {
|
||||||
|
error.appendTo(element.parent());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// $form.on("submit", function (e) {
|
||||||
|
// if (!$form.valid()) {
|
||||||
|
// e.preventDefault(); // Ne küldje be, ha van hiba
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
}
|
||||||
@@ -1,12 +1,49 @@
|
|||||||
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.Web.Services.Interfaces;
|
||||||
|
|
||||||
namespace WorkFlowCheck.Web.Pages.BaseStock.Equipments
|
namespace WorkFlowCheck.Web.Pages.BaseStock.Equipments
|
||||||
{
|
{
|
||||||
public class EquipmentEditPageModel : PageModel
|
public class EquipmentEditPageModel : PageModel
|
||||||
{
|
{
|
||||||
public void OnGet()
|
private readonly ILogger<IndexModel> _logger;
|
||||||
|
private readonly IBaseStockService _baseStockService;
|
||||||
|
|
||||||
|
[BindProperty]
|
||||||
|
public EquipmentDTO EquipmentDTO { get; set; }
|
||||||
|
|
||||||
|
public EquipmentEditPageModel(ILogger<IndexModel> logger, IBaseStockService baseStockService)
|
||||||
{
|
{
|
||||||
|
_baseStockService = baseStockService;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task OnGet(int id)
|
||||||
|
{
|
||||||
|
EquipmentDTO = await _baseStockService.GetEquipment(id);
|
||||||
|
}
|
||||||
|
public async Task<IActionResult> OnPostSave([FromBody] EquipmentDTO equipmentDTO)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await _baseStockService.UpdateEquipment(equipmentDTO);
|
||||||
|
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 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,16 @@
|
|||||||
|
|
||||||
<div class="card shadow p-4">
|
<div class="card shadow p-4">
|
||||||
<div class="d-flex justify-content-end">
|
<div class="d-flex justify-content-end">
|
||||||
<button class="btn btn-primary float-right">Új elem hozzáadása</button>
|
<button id="newEquipmentBtn" class="btn btn-primary float-right new-btn" data-bs-toggle="tooltip" data-bs-placement="top" title="Új berendezés">
|
||||||
|
<i class="bi bi-plus-square"></i>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<table id="tbEquipmentsPage" class="table table-bordered table-hover table-sm" style="width:100%">
|
<table id="tbEquipmentsPage" class="table table-bordered table-hover table-sm" style="width:100%">
|
||||||
<thead class="table-primary">
|
<thead class="table-primary">
|
||||||
<tr>
|
<tr>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
<th>Short Name</th>
|
<th>Short Name</th>
|
||||||
|
<th>Equipment Number</th>
|
||||||
<th class="text-center">Action</th>
|
<th class="text-center">Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -21,6 +24,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
<th>Short Name</th>
|
<th>Short Name</th>
|
||||||
|
<th>Equipment Number</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
@@ -38,6 +42,7 @@
|
|||||||
columns: [
|
columns: [
|
||||||
{ data: "id" },
|
{ data: "id" },
|
||||||
{ data: "shortName" },
|
{ data: "shortName" },
|
||||||
|
{ data: "equipmentNumber" },
|
||||||
{ data: null, render: function (data, type, row) {
|
{ data: null, render: function (data, type, row) {
|
||||||
return renderActionButtons(row.id);
|
return renderActionButtons(row.id);
|
||||||
}}
|
}}
|
||||||
@@ -48,9 +53,9 @@
|
|||||||
"visible": false
|
"visible": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"targets": 2,
|
"targets": 3,
|
||||||
"className": "text-center",
|
"className": "text-center",
|
||||||
"width": "10"
|
"width": "10%"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -58,6 +63,11 @@
|
|||||||
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
|
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#newEquipmentBtn').on('click', function ()
|
||||||
|
{
|
||||||
|
window.location.href = `@Url.Page("/BaseStock/Equipments/EquipmentEditPage")?id=0`;
|
||||||
|
});
|
||||||
|
|
||||||
$('#tbEquipmentsPage').on('click', '.edit-btn', function ()
|
$('#tbEquipmentsPage').on('click', '.edit-btn', function ()
|
||||||
{
|
{
|
||||||
const row = table.row($(this).closest('tr')).data();
|
const row = table.row($(this).closest('tr')).data();
|
||||||
|
|||||||
+10
-2
@@ -31,7 +31,7 @@
|
|||||||
<br></br>
|
<br></br>
|
||||||
<div class="card shadow p-4">
|
<div class="card shadow p-4">
|
||||||
<div class="d-flex justify-content-end">
|
<div class="d-flex justify-content-end">
|
||||||
<button id="newCheckListTemplateHeaderBtn" class="btn btn-primary float-right new-btn" data-bs-toggle="tooltip" data-bs-placement="top" title="Új elem hozzáadása">
|
<button id="newCheckListTemplateRowBtn" class="btn btn-primary float-right new-btn" data-bs-toggle="tooltip" data-bs-placement="top" title="Új elem hozzáadása">
|
||||||
<i class="bi bi-plus-square"></i>
|
<i class="bi bi-plus-square"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -91,11 +91,19 @@
|
|||||||
processing:true,
|
processing:true,
|
||||||
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
|
language: { url: '//cdn.datatables.net/plug-ins/2.2.2/i18n/hu.json',}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$('#newCheckListTemplateRowBtn').on('click', function () {
|
||||||
|
const parentId = @CheckListTemplateHeaderId;
|
||||||
|
window.location.href = '@Url.Page("/CheckListTemplate/CheckListTemplateRows/CheckListTemplateRowEditPage", "New")' + `&parentId=${parentId}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
$('#tbCheckListTemplateHeaderPage').on('click', '.edit-btn', function ()
|
$('#tbCheckListTemplateHeaderPage').on('click', '.edit-btn', function ()
|
||||||
{
|
{
|
||||||
const row = table.row($(this).closest('tr')).data();
|
const row = table.row($(this).closest('tr')).data();
|
||||||
window.location.href = `@Url.Page("/CheckListTemplate/CheckListTemplateRows/CheckListTemplateRowEditPage")?id=${row.id}`;
|
window.location.href = `@Url.Page("/CheckListTemplate/CheckListTemplateRows/CheckListTemplateRowEditPage")?id=${row.id}`;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#tbCheckListTemplateHeaderPage').on('click', '.delete-btn', function ()
|
$('#tbCheckListTemplateHeaderPage').on('click', '.delete-btn', function ()
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
@page
|
@page
|
||||||
@model WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateRows.CheckListTemplateRowEditPageModel
|
@model WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateRows.CheckListTemplateRowEditPageModel
|
||||||
@using Microsoft.AspNetCore.Antiforgery
|
@using Microsoft.AspNetCore.Antiforgery
|
||||||
@inject IAntiforgery Antiforgery
|
@inject IAntiforgery Antiforgery
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
'X-CSRF-TOKEN': csrfToken,
|
'X-CSRF-TOKEN': csrfToken,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
data: JSON.stringify(formData.CheckPoint),
|
data: JSON.stringify(formData.CheckListTemplateRow),
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
showMessageModal({
|
showMessageModal({
|
||||||
title: 'Figyelmem!',
|
title: 'Figyelmem!',
|
||||||
|
|||||||
+63
-2
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
|
using Serilog;
|
||||||
using WorkFlowCheck.Common.DTO;
|
using WorkFlowCheck.Common.DTO;
|
||||||
using WorkFlowCheck.Web.Services.Interfaces;
|
using WorkFlowCheck.Web.Services.Interfaces;
|
||||||
|
|
||||||
@@ -9,6 +10,7 @@ namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateRows
|
|||||||
public class CheckListTemplateRowEditPageModel : PageModel
|
public class CheckListTemplateRowEditPageModel : PageModel
|
||||||
{
|
{
|
||||||
private readonly ILogger<IndexModel> _logger;
|
private readonly ILogger<IndexModel> _logger;
|
||||||
|
private readonly ICheckListService _checkListService;
|
||||||
private readonly IBaseStockService _baseStockService;
|
private readonly IBaseStockService _baseStockService;
|
||||||
|
|
||||||
|
|
||||||
@@ -27,8 +29,9 @@ namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateRows
|
|||||||
[BindProperty]
|
[BindProperty]
|
||||||
public List<SelectListItem> Equipments { get; set; }
|
public List<SelectListItem> Equipments { get; set; }
|
||||||
|
|
||||||
public CheckListTemplateRowEditPageModel(ILogger<IndexModel> logger, IBaseStockService baseStockService)
|
public CheckListTemplateRowEditPageModel(ILogger<IndexModel> logger, ICheckListService checkListService, IBaseStockService baseStockService)
|
||||||
{
|
{
|
||||||
|
_checkListService = checkListService;
|
||||||
_baseStockService = baseStockService;
|
_baseStockService = baseStockService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
@@ -36,7 +39,64 @@ namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateRows
|
|||||||
public async Task OnGet(int id)
|
public async Task OnGet(int id)
|
||||||
{
|
{
|
||||||
await InitSelectItems();
|
await InitSelectItems();
|
||||||
CheckListTemplateRow = await _baseStockService.GetCheckListTemplateRow(id);
|
CheckListTemplateRow = await _checkListService.GetCheckListTemplateRow(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task OnGetNew(int parentId)
|
||||||
|
{
|
||||||
|
await InitSelectItems();
|
||||||
|
|
||||||
|
var checkListTemplateHeader = await _checkListService.GetCheckListTemplateHeader(parentId);
|
||||||
|
|
||||||
|
if (checkListTemplateHeader != null)
|
||||||
|
{
|
||||||
|
int rowIndex = 1;
|
||||||
|
int equipmentId = 0;
|
||||||
|
int checkPointId = 0;
|
||||||
|
|
||||||
|
if (checkListTemplateHeader.CheckListTemplateRowDTO.Count() > 0)
|
||||||
|
{
|
||||||
|
var checkListTemplateRowMax = checkListTemplateHeader.CheckListTemplateRowDTO.OrderByDescending(o => o.RowIndex).FirstOrDefault();
|
||||||
|
if (checkListTemplateRowMax != null)
|
||||||
|
{
|
||||||
|
rowIndex = checkListTemplateRowMax.RowIndex + 1;
|
||||||
|
checkPointId=checkListTemplateRowMax.CheckPointId;
|
||||||
|
equipmentId= checkListTemplateRowMax.EquipmentId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckListTemplateRow = new CheckListTemplateRowDTO()
|
||||||
|
{
|
||||||
|
Id = 0,
|
||||||
|
CheckListTemplateHeaderId = parentId,
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
EquipmentId = equipmentId,
|
||||||
|
CheckPointId = checkPointId,
|
||||||
|
AnswerType = "I-N"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public async Task<IActionResult> OnPostSave([FromBody] CheckListTemplateRowDTO checkListTemplateRowDTO)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await _checkListService.UpdateCheckListTemplateRow(checkListTemplateRowDTO);
|
||||||
|
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 async Task InitSelectItems()
|
private async Task InitSelectItems()
|
||||||
{
|
{
|
||||||
@@ -53,5 +113,6 @@ namespace WorkFlowCheck.Web.Pages.CheckListTemplate.CheckListTemplateRows
|
|||||||
this.Equipments.Add(new SelectListItem() { Value = equipment.Id.ToString(), Text = equipment.ShortName });
|
this.Equipments.Add(new SelectListItem() { Value = equipment.Id.ToString(), Text = equipment.ShortName });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,8 +75,16 @@ app.UseAuthorization();
|
|||||||
|
|
||||||
app.Use(async (context, next) =>
|
app.Use(async (context, next) =>
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(context.User?.Identity?.Name) &&
|
//if (string.IsNullOrEmpty(context.User?.Identity?.Name) &&
|
||||||
context.Request.Path == "/")
|
// context.Request.Path == "/")
|
||||||
|
//{
|
||||||
|
// context.Response.Redirect("/Account/Login");
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
var isAuthenticated = context.User?.Identity?.IsAuthenticated == true;
|
||||||
|
var path = context.Request.Path.Value?.ToLower();
|
||||||
|
|
||||||
|
if (!isAuthenticated && !path.StartsWith("/account/login"))
|
||||||
{
|
{
|
||||||
context.Response.Redirect("/Account/Login");
|
context.Response.Redirect("/Account/Login");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace WorkFlowCheck.Web.Services
|
|||||||
|
|
||||||
public async Task<CheckPointDTO> GetCheckPoint(int id)
|
public async Task<CheckPointDTO> GetCheckPoint(int id)
|
||||||
{
|
{
|
||||||
string endpoint = $"{_httpClient.BaseAddress}api/Sync/GetCheckPoints/{id}";
|
string endpoint = $"{_httpClient.BaseAddress}api/Sync/GetCheckPoint/{id}";
|
||||||
var retVal = new CheckPointDTO();
|
var retVal = new CheckPointDTO();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -142,28 +142,7 @@ namespace WorkFlowCheck.Web.Services
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id)
|
|
||||||
{
|
|
||||||
string endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetCheckListTemplateRow/{id}";
|
|
||||||
var retVal = new CheckListTemplateRowDTO();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<CheckListTemplateRowDTO>>(endpoint);
|
|
||||||
if (response != null)
|
|
||||||
{
|
|
||||||
if (response.IsSuccess)
|
|
||||||
{
|
|
||||||
return response.Data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.Error(ex.Message);
|
|
||||||
}
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<ApiResponseDTO<CheckPointDTO>> UpdateCheckPoint(CheckPointDTO checkPointDTO)
|
public async Task<ApiResponseDTO<CheckPointDTO>> UpdateCheckPoint(CheckPointDTO checkPointDTO)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Serilog;
|
using Newtonsoft.Json;
|
||||||
|
using Serilog;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using WorkFlowCheck.Common.DTO;
|
using WorkFlowCheck.Common.DTO;
|
||||||
using WorkFlowCheck.Web.Services.Interfaces;
|
using WorkFlowCheck.Web.Services.Interfaces;
|
||||||
@@ -99,5 +100,56 @@ namespace WorkFlowCheck.Web.Services
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
public async Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO) => throw new NotImplementedException();
|
public async Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO) => throw new NotImplementedException();
|
||||||
|
|
||||||
|
public async Task<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id)
|
||||||
|
{
|
||||||
|
string endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetCheckListTemplateRow/{id}";
|
||||||
|
var retVal = new CheckListTemplateRowDTO();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<CheckListTemplateRowDTO>>(endpoint);
|
||||||
|
if (response != null)
|
||||||
|
{
|
||||||
|
if (response.IsSuccess)
|
||||||
|
{
|
||||||
|
return response.Data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex.Message);
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
public async Task<ApiResponseDTO<CheckListTemplateRowDTO>> UpdateCheckListTemplateRow(CheckListTemplateRowDTO checkListTemplateRowDTO)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string endpoint = $"{_httpClient.BaseAddress}api/CheckList/UpdateCheckListTemplateRow";
|
||||||
|
|
||||||
|
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, checkListTemplateRowDTO))
|
||||||
|
{
|
||||||
|
httpResponseMessage.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
|
var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||||
|
var response = JsonConvert.DeserializeObject<ApiResponseDTO<CheckListTemplateRowDTO>>(jsonString);
|
||||||
|
|
||||||
|
return response ?? new ApiResponseDTO<CheckListTemplateRowDTO>
|
||||||
|
{
|
||||||
|
IsSuccess = false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Hiba visszaadása
|
||||||
|
return new ApiResponseDTO<CheckListTemplateRowDTO>
|
||||||
|
{
|
||||||
|
IsSuccess = false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,18 @@ namespace WorkFlowCheck.Web.Services.Interfaces
|
|||||||
{
|
{
|
||||||
public interface IBaseStockService
|
public interface IBaseStockService
|
||||||
{
|
{
|
||||||
Task<List<CheckPointDTO>> GetAllCheckPoints();
|
|
||||||
Task<List<EquipmentDTO>> GetAllEquipments();
|
|
||||||
Task<List<LocationDTO>> GetAllLocations();
|
|
||||||
Task<CheckPointDTO> GetCheckPoint(int id);
|
Task<CheckPointDTO> GetCheckPoint(int id);
|
||||||
Task<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id);
|
Task<List<CheckPointDTO>> GetAllCheckPoints();
|
||||||
Task<ApiResponseDTO<CheckPointDTO>> UpdateCheckPoint(CheckPointDTO checkPoint);
|
Task<ApiResponseDTO<CheckPointDTO>> UpdateCheckPoint(CheckPointDTO checkPointDTO);
|
||||||
|
|
||||||
|
|
||||||
|
Task<EquipmentDTO> GetEquipment(int id);
|
||||||
|
Task<List<EquipmentDTO>> GetAllEquipments();
|
||||||
|
Task<ApiResponseDTO<EquipmentDTO>> UpdateEquipment(EquipmentDTO equipmentDTO);
|
||||||
|
|
||||||
|
Task<LocationDTO> GetLocation(int id);
|
||||||
|
Task<List<LocationDTO>> GetAllLocations();
|
||||||
|
Task<ApiResponseDTO<LocationDTO>> UpdateLocation(LocationDTO LocationDTO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,8 @@ namespace WorkFlowCheck.Web.Services.Interfaces
|
|||||||
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync();
|
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync();
|
||||||
Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO);
|
Task<ApiResponseDTO<CheckListTemplateHeaderDTO>> UpdateCheckListTemplateHeader(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO);
|
||||||
|
|
||||||
|
Task<CheckListTemplateRowDTO> GetCheckListTemplateRow(int id);
|
||||||
|
Task<ApiResponseDTO<CheckListTemplateRowDTO>> UpdateCheckListTemplateRow(CheckListTemplateRowDTO checkListTemplateRowDTO);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user