Skip to content
Snippets Groups Projects

Course template

Merged Lucca Santangelo Dodera requested to merge course-template into develop
13 files
+ 762
21
Compare changes
  • Side-by-side
  • Inline
Files
13
@@ -170,10 +170,25 @@ namespace Tsi1.Api.Controllers
@@ -170,10 +170,25 @@ namespace Tsi1.Api.Controllers
return Ok(result.Data);
return Ok(result.Data);
}
}
 
[Authorize(Roles = UserTypes.FacultyAdmin)]
 
[HttpGet("GetAllTemplates")]
 
public async Task<IActionResult> GetAllTemplates()
 
{
 
var tenantId = int.Parse(HttpContext.User.Claims.FirstOrDefault(x => x.Type == "TenantId").Value);
 
 
var result = await _courseService.GetAll(tenantId, true);
 
if (result.HasError)
 
{
 
return BadRequest(result.Message);
 
}
 
 
return Ok(result.Data);
 
}
 
[Authorize(Roles = UserTypes.Professor + ", " + UserTypes.FacultyAdmin)]
[Authorize(Roles = UserTypes.Professor + ", " + UserTypes.FacultyAdmin)]
[HttpPut("Modify/{courseId}")]
[HttpPut("Modify/{courseId}")]
public async Task<IActionResult> Modify(int courseId, CourseCreateDto courseDto)
public async Task<IActionResult> Modify(int courseId, CourseModifyDto courseDto)
{
{
var tenantId = int.Parse(HttpContext.User.Claims.FirstOrDefault(x => x.Type == "TenantId").Value);
var tenantId = int.Parse(HttpContext.User.Claims.FirstOrDefault(x => x.Type == "TenantId").Value);
courseDto.TenantId = tenantId;
courseDto.TenantId = tenantId;
@@ -238,5 +253,19 @@ namespace Tsi1.Api.Controllers
@@ -238,5 +253,19 @@ namespace Tsi1.Api.Controllers
return Ok(result.Data);
return Ok(result.Data);
}
}
 
[AllowAnonymous]
 
[Authorize(Roles = UserTypes.FacultyAdmin)]
 
[HttpPost("CreateFromTemplate")]
 
public async Task<IActionResult> CreateFromTemplate(CourseTemplateCreateDto courseTemplate)
 
{
 
var tenantId = int.Parse(HttpContext.User.Claims.FirstOrDefault(x => x.Type == "TenantId").Value);
 
 
var result = await _courseService.CreateFromTemplate(courseTemplate, tenantId);
 
if (result.HasError)
 
{
 
return BadRequest(result.Message);
 
}
 
return Ok();
 
}
}
}
}
}
Loading