mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 06:03:12 +00:00
36 lines
1,022 B
C#
36 lines
1,022 B
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using SeaHaven.Services.DTOs;
|
|
using SeaHaven.Services.Interfaces;
|
|
|
|
namespace Api.SeaHavenIndustries.Controllers;
|
|
|
|
[Authorize]
|
|
[ApiController]
|
|
[Route("api/team-members")]
|
|
public sealed class TeamMemberController : ControllerBase
|
|
{
|
|
private readonly ITeamMemberService _teamMemberService;
|
|
|
|
public TeamMemberController(ITeamMemberService teamMemberService)
|
|
{
|
|
_teamMemberService = teamMemberService;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> Create(
|
|
CreateTeamMemberRequestDTO request,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
var outcome = await _teamMemberService.CreateAsync(request, User, cancellationToken);
|
|
if (!outcome.Success)
|
|
{
|
|
if (string.Equals(outcome.Error, "Forbidden", StringComparison.Ordinal))
|
|
return Forbid();
|
|
|
|
return BadRequest(new { message = outcome.Error });
|
|
}
|
|
|
|
return Ok(outcome.Member);
|
|
}
|
|
}
|