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

add evaluation type endpoints

parent 35076524
No related branches found
No related tags found
1 merge request!39Feature/fix evaluations
...@@ -16,10 +16,13 @@ namespace Tsi1.Api.Controllers ...@@ -16,10 +16,13 @@ namespace Tsi1.Api.Controllers
public class EvaluationController : ControllerBase public class EvaluationController : ControllerBase
{ {
private readonly IEvaluationService _evaluationService; private readonly IEvaluationService _evaluationService;
private readonly IEvaluationTypeService _evaluationTypeService;
public EvaluationController(IEvaluationService evaluationService)
public EvaluationController(IEvaluationService evaluationService, IEvaluationTypeService evaluationTypeService)
{ {
_evaluationService = evaluationService; _evaluationService = evaluationService;
_evaluationTypeService = evaluationTypeService;
} }
[Authorize(Roles = UserTypes.Student)] [Authorize(Roles = UserTypes.Student)]
...@@ -134,5 +137,33 @@ namespace Tsi1.Api.Controllers ...@@ -134,5 +137,33 @@ namespace Tsi1.Api.Controllers
return Ok(result.Data); return Ok(result.Data);
} }
[Authorize(Roles = UserTypes.Student + ", " + UserTypes.FacultyAdmin + ", " + UserTypes.Professor)]
[HttpGet("GetEvaluationTypes")]
public async Task<IActionResult> GetEvaluationTypes()
{
var result = await _evaluationTypeService.GetAll();
if (result.HasError)
{
return BadRequest(result.Message);
}
return Ok(result.Data);
}
[Authorize(Roles = UserTypes.Student + ", " + UserTypes.FacultyAdmin + ", " + UserTypes.Professor)]
[HttpGet("GetEvaluationTypeById/{evaluationTypeId}")]
public async Task<IActionResult> GetEvaluationTypeById(int evaluationTypeId)
{
var result = await _evaluationTypeService.GetById(evaluationTypeId);
if (result.HasError)
{
return BadRequest(result.Message);
}
return Ok(result.Data);
}
} }
} }
...@@ -107,6 +107,7 @@ namespace Tsi1.Api ...@@ -107,6 +107,7 @@ namespace Tsi1.Api
services.AddScoped<IChatService, ChatService>(); services.AddScoped<IChatService, ChatService>();
services.AddScoped<IActivityService, ActivityService>(); services.AddScoped<IActivityService, ActivityService>();
services.AddScoped<IEvaluationService, EvaluationService>(); services.AddScoped<IEvaluationService, EvaluationService>();
services.AddScoped<IEvaluationTypeService, EvaluationTypeService>();
services.AddSingleton<PresenceTracker>(); services.AddSingleton<PresenceTracker>();
......
...@@ -11,6 +11,6 @@ namespace Tsi1.BusinessLayer.Interfaces ...@@ -11,6 +11,6 @@ namespace Tsi1.BusinessLayer.Interfaces
{ {
public Task<ServiceResult<EvaluationTypeDto>> GetById(int id); public Task<ServiceResult<EvaluationTypeDto>> GetById(int id);
public Task<ServiceResult<List<EvaluationTypeDto>>> GetAll(string userType); public Task<ServiceResult<List<EvaluationTypeDto>>> GetAll();
} }
} }
...@@ -22,7 +22,7 @@ namespace Tsi1.BusinessLayer.Services ...@@ -22,7 +22,7 @@ namespace Tsi1.BusinessLayer.Services
_mapper = mapper; _mapper = mapper;
} }
public async Task<ServiceResult<List<EvaluationTypeDto>>> GetAll(string userType) public async Task<ServiceResult<List<EvaluationTypeDto>>> GetAll()
{ {
var result = new ServiceResult<List<EvaluationTypeDto>>(); var result = new ServiceResult<List<EvaluationTypeDto>>();
......
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