Skip to content
Snippets Groups Projects

crud Courses

Merged Enzo Santangelo Dodera requested to merge feature/Courses into develop
4 files
+ 134
1
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -85,5 +85,73 @@ namespace Tsi1.Api.Controllers
return Ok();
}
[Authorize(Roles = UserTypes.Student + ", " + UserTypes.Professor + ", " + UserTypes.FacultyAdmin)]
[HttpGet("GetAll")]
public async Task<IActionResult> GetAll()
{
var tenantId = int.Parse(HttpContext.User.Claims.FirstOrDefault(x => x.Type == "TenantId").Value);
var result = await _courseService.GetAll(tenantId);
if (result.HasError)
{
return BadRequest(result.Message);
}
return Ok(result.Data);
}
[Authorize(Roles = UserTypes.UdelarAdmin)]
[HttpGet("GetAll/{tenantId}")]
public async Task<IActionResult> GetAll(int tenantId)
{
var result = await _courseService.GetAll(tenantId);
if (result.HasError)
{
return BadRequest(result.Message);
}
return Ok(result.Data);
}
[Authorize(Roles = UserTypes.Professor + ", " + UserTypes.FacultyAdmin)]
[HttpPut("Modify/{courseId}")]
public async Task<IActionResult> Modify(int courseId, CourseCreateDto courseDto)
{
var result = await _courseService.Modify(courseId, courseDto);
if (result.HasError)
{
return BadRequest(result.Message);
}
if (result.Data == false)
{
return NotFound(result.Message);
}
return Ok();
}
[Authorize(Roles = UserTypes.FacultyAdmin)]
[HttpDelete("Delete/{courseId}")]
public async Task<IActionResult> Delete(int courseId)
{
var result = await _courseService.Delete(courseId);
if (result.HasError)
{
return BadRequest(result.Message);
}
if (result.Data == false)
{
return NotFound(result.Message);
}
return Ok();
}
}
}
Loading