Skip to content
Snippets Groups Projects

Feature/upload file

Merged Enzo Santangelo Dodera requested to merge feature/upload-file into develop
9 files
+ 67
11
Compare changes
  • Side-by-side
  • Inline
Files
9
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
@@ -19,9 +20,12 @@ namespace Tsi1.Api.Controllers
{
private readonly ICourseService _courseService;
public CourseController(ICourseService courseService)
private readonly IFileService _fileService;
public CourseController(ICourseService courseService, IFileService fileService)
{
_courseService = courseService;
_fileService = fileService;
}
[Authorize(Roles = UserTypes.Student + ", " + UserTypes.Professor)]
@@ -54,6 +58,10 @@ namespace Tsi1.Api.Controllers
return BadRequest(result.Message);
}
var path = Path.Combine(tenantId.ToString(), result.Data.Id.ToString());
_fileService.CreateFolder(path);
return Ok();
}
@@ -197,11 +205,15 @@ namespace Tsi1.Api.Controllers
return BadRequest(result.Message);
}
if (result.Data == false)
if (result.Data == null)
{
return NotFound(result.Message);
}
var path = Path.Combine(result.Data.TenantId.ToString(), result.Data.Id.ToString());
_fileService.DeleteFolder(path);
return Ok();
}
Loading