using e_suite.API.Common;
using eSuite.API.security;
using eSuite.API.Utilities;
using eSuite.Core.Security;
using Microsoft.AspNetCore.Mvc;

namespace eSuite.API.Controllers;

[Route("api/[controller]")]
[ApiController]
public class ActivityController : ESuiteControllerBase
{
    private readonly IActivityManager _activityManager;

    public ActivityController(IActivityManager activityManager)
    {
        _activityManager = activityManager;
    }

    /// <summary>
    /// Create a new workflow template
    /// </summary>
    /// <remarks>Create a new user for e-suite.  The minimum information needed is the email address, which forms the account user name.  Once created the user will get an e-mail asking them to confirm the account.</remarks>
    /// <param name="userRegistration">Contains the details that need to be supplied to create the user.</param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    [Route("activity")]
    [HttpPost]
    [ProducesResponseType(StatusCodes.Status200OK)]
    [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ProblemDetails))]
    [AccessKey(SecurityAccess.AddWorkflowTemplate)]
    public async Task<IActionResult> CreateWorkflowTemplateVersion(
        [FromBody] CreateActivity template,
        CancellationToken cancellationToken = default!
    )
    {
        await _activityManager.CreateActivity(AuditUserDetails, template, cancellationToken);
        return Ok();
    }
}