Controller javítása userId-vel
This commit is contained in:
@@ -20,6 +20,7 @@ namespace WorkFlowCheck.BL.Services.Interfaces
|
||||
Task<EquipmentDTO> UpdateEquipmentAsync(EquipmentDTO EquipmentDTO);
|
||||
|
||||
|
||||
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateAsync();
|
||||
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateAsync(int userId);
|
||||
Task<List<CheckListHeaderDTO>> GetAllCheckListAsync(int userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,9 +101,9 @@ namespace WorkFlowCheck.BL.Services
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<List<LocationDTO>> GetAllLocationAsync()
|
||||
{
|
||||
var retVal = new List<LocationDTO>();
|
||||
@@ -164,7 +164,7 @@ namespace WorkFlowCheck.BL.Services
|
||||
var res = await _dbContext.Locations.Where(w => w.Id == LocationDTO.Id).FirstOrDefaultAsync();
|
||||
if (res != null)
|
||||
{
|
||||
res=_mapper.Map<Location>(LocationDTO);
|
||||
res = _mapper.Map<Location>(LocationDTO);
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
@@ -260,18 +260,54 @@ namespace WorkFlowCheck.BL.Services
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateAsync()
|
||||
public async Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateAsync(int userId)
|
||||
{
|
||||
var retVal = new List<CheckListTemplateHeaderDTO>();
|
||||
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.CheckListTemplateHeaders.Include(i => i.CheckListTemplateRows).AsNoTracking().ToListAsync();
|
||||
var user = _dbContext.Users.Where(w => w.Id == userId).FirstOrDefault();
|
||||
if (user != null)
|
||||
{
|
||||
var res = await (from ur in _dbContext.UserRoles
|
||||
join rth in _dbContext.RoleCheckListTemplateHeaders on ur.RoleId equals rth.RoleId
|
||||
join header in _dbContext.CheckListTemplateHeaders on rth.CheckListTemplateHeaderId equals header.Id
|
||||
where ur.UserId == userId
|
||||
select header)
|
||||
.Include(h => h.CheckListTemplateRows)
|
||||
.Distinct()
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<CheckListTemplateHeaderDTO>>(res);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<CheckListHeaderDTO>> GetAllCheckListAsync(int userId)
|
||||
{
|
||||
var retVal = new List<CheckListHeaderDTO>();
|
||||
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.CheckListHeaders
|
||||
.Where(w => w.IsEditable && w.UserId == userId)
|
||||
.Include(i => i.CheckListRows)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<CheckListTemplateHeaderDTO>>(res);
|
||||
|
||||
retVal = _mapper.Map<List<CheckListHeaderDTO>>(res);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user