Skip to content
Snippets Groups Projects
Commit ce0a059a authored by esantangelo's avatar esantangelo
Browse files

add endpoint GetAllGlobalCommunications

parent 9dc60e4f
No related branches found
No related tags found
1 merge request!31Develop
Pipeline #10413 failed
......@@ -119,6 +119,20 @@ namespace Tsi1.Api.Controllers
return Ok(result.Data);
}
[Authorize(Roles = UserTypes.UdelarAdmin)]
[HttpGet("GetAllGlobalCommunications")]
public async Task<IActionResult> GetAllGlobalCommunications()
{
var result = await _communicationService.GetAllGlobalCommunications();
if (result.HasError)
{
return BadRequest(result.Message);
}
return Ok(result.Data);
}
[Authorize(Roles = UserTypes.FacultyAdmin + ", " + UserTypes.UdelarAdmin)]
[HttpDelete("Delete/{communicationId}")]
public async Task<IActionResult> Delete(int communicationId)
......
......@@ -20,5 +20,6 @@ namespace Tsi1.BusinessLayer.Interfaces
Task<ServiceResult<List<CommunicationPreviewDto>>> GetGlobalCommunications(int tenantId);
Task<ServiceResult<bool>> TenantValidation(int tenantId, int courseId);
Task<ServiceResult<List<CommunicationPreviewDto>>> GetAllGlobalCommunications();
}
}
......@@ -190,5 +190,20 @@ namespace Tsi1.BusinessLayer.Services
return result;
}
public async Task<ServiceResult<List<CommunicationPreviewDto>>> GetAllGlobalCommunications()
{
var result = new ServiceResult<List<CommunicationPreviewDto>>();
var communications = await _context.Communications
.AsNoTracking()
.Include(x => x.Tenant)
.Where(x => x.IsGlobal)
.ToListAsync();
result.Data = _mapper.Map<List<CommunicationPreviewDto>>(communications);
return result;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment