Skip to content
Snippets Groups Projects

remove https and docker

Merged Lucca Santangelo Dodera requested to merge feature/remove-https into master
51 files
+ 2485
2
Compare changes
  • Side-by-side
  • Inline
Files
51
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.Dtos;
using Tsi1.BusinessLayer.Helpers;
using Tsi1.BusinessLayer.Interfaces;
namespace Tsi1.Api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ForumController : ControllerBase
{
private readonly IForumService _forumService;
public ForumController(IForumService forumService)
{
_forumService = forumService;
}
[Authorize(Roles = UserTypes.Student + ", " + UserTypes.Professor)]
[HttpGet("GetForums/{courseId}")]
public async Task<IActionResult> GetForums(int courseId)
{
var result = await _forumService.GetForums(courseId);
if (result.HasError)
{
return BadRequest(result.Message);
}
return Ok(result.Data);
}
[Authorize(UserTypes.Professor)]
[HttpPost("Create")]
public async Task<IActionResult> Create(ForumCreateDto newForum)
{
var result = await _forumService.Create(newForum);
if (result.HasError)
{
return BadRequest(result.Message);
}
return Ok();
}
[Authorize(UserTypes.Professor)]
[HttpDelete("Delete/{forumId}")]
public async Task<IActionResult> Delete(int forumId)
{
var result = await _forumService.Delete(forumId);
if (result.HasError)
{
return BadRequest(result.Message);
}
return Ok();
}
[Authorize(Roles = UserTypes.Student)]
[HttpGet("Subscribe/{forumId}")]
public async Task<IActionResult> Subscribe(int forumId)
{
var userId = int.Parse(HttpContext.User.Claims.FirstOrDefault(x => x.Type == "Id").Value);
var result = await _forumService.Subscribe(forumId, userId);
if (result.HasError)
{
return BadRequest(result.Message);
}
return Ok();
}
}
}
Loading