37 lines
1.4 KiB
C#
37 lines
1.4 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|||
|
|
using Microsoft.AspNetCore.Mvc;
|
||
|
|
using Mws.Application.Projects;
|
||
|
|
|
||
|
|
namespace Mws.Api.Controllers;
|
||
|
|
|
||
|
|
[ApiController]
|
||
|
|
[Route("api/projects/{projectId:guid}/members")]
|
||
|
|
[Authorize]
|
||
|
|
public class ProjectMembersController(IProjectMemberService memberService) : ControllerBase
|
||
|
|
{
|
||
|
|
[HttpGet]
|
||
|
|
public async Task<ActionResult<List<ProjectMemberDto>>> GetAll(Guid projectId, CancellationToken ct)
|
||
|
|
{
|
||
|
|
return Ok(await memberService.GetMembersAsync(User.GetUserId(), projectId, ct));
|
||
|
|
}
|
||
|
|
|
||
|
|
[HttpPost]
|
||
|
|
public async Task<ActionResult<ProjectMemberDto>> Add(Guid projectId, [FromBody] AddMemberRequest request, CancellationToken ct)
|
||
|
|
{
|
||
|
|
return Ok(await memberService.AddMemberAsync(User.GetUserId(), projectId, request, ct));
|
||
|
|
}
|
||
|
|
|
||
|
|
[HttpPut("{userId:guid}/document-permissions")]
|
||
|
|
public async Task<ActionResult<ProjectMemberDto>> UpdateDocumentPermissions(
|
||
|
|
Guid projectId, Guid userId, [FromBody] UpdateMemberDocumentPermissionsRequest request, CancellationToken ct)
|
||
|
|
{
|
||
|
|
return Ok(await memberService.UpdateMemberDocumentPermissionsAsync(User.GetUserId(), projectId, userId, request, ct));
|
||
|
|
}
|
||
|
|
|
||
|
|
[HttpDelete("{userId:guid}")]
|
||
|
|
public async Task<IActionResult> Remove(Guid projectId, Guid userId, CancellationToken ct)
|
||
|
|
{
|
||
|
|
await memberService.RemoveMemberAsync(User.GetUserId(), projectId, userId, ct);
|
||
|
|
return NoContent();
|
||
|
|
}
|
||
|
|
}
|