Skip to content
Snippets Groups Projects

Feature/upload file

Merged Enzo Santangelo Dodera requested to merge feature/upload-file into develop
17 files
+ 1310
0
Compare changes
  • Side-by-side
  • Inline
Files
17
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Tsi1.BusinessLayer.Helpers;
using Tsi1.BusinessLayer.Interfaces;
namespace Tsi1.Api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class FileController : ControllerBase
{
private readonly IFileService _fileService;
public FileController(IFileService fileService)
{
_fileService = fileService;
}
[Authorize(Roles = UserTypes.Professor)]
[HttpPost("Create/{courseId}")]
public async Task<IActionResult> Create(IFormFile file, int courseId)
{
var tenantId = int.Parse(HttpContext.User.Claims.FirstOrDefault(x => x.Type == "TenantId").Value);
var result = await _fileService.Create(file, tenantId, courseId);
if (result.HasError)
{
return BadRequest(result.Message);
}
return Ok(result.Data);
}
}
}
Loading