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

namespace eSuite.API.Controllers;

/// <summary>
/// User manage is responsible for managing users within e-suite.
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class TasksController : ESuiteControllerBase
{
    private readonly IActivityManager _activityManager;
    //private readonly IWorkflowTemplateManager _workflowTemplateManager;

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


    /// <summary>
    /// Get my current assignments
    /// </summary>
    /// <param name="paging"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    /// <exception cref="NotImplementedException"></exception>
    [Route("myTasks")]
    [AccessKey(SecurityAccess.ViewTasks)]
    [HttpGet]
    public async Task<IActionResult> GetMyTasks(
        [FromQuery] Paging paging,
        CancellationToken cancellationToken = default!
    )
    {
        var result = await _activityManager.GetMyActiveAssignmentsAsync(AuditUserDetails, paging, cancellationToken);
        return Ok(result);
    }

    /// <summary>
    /// Get the details of an assignment
    /// </summary>
    /// <param name="assignmentId"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    /// <exception cref="NotImplementedException"></exception>
    [Route("getAssignmentDetails")]
    [AccessKey(SecurityAccess.ViewTasks)]
    [HttpGet]
    public async Task<IActionResult> GetAssignmentDetails( [FromQuery] GeneralIdRef assignmentId, CancellationToken cancellationToken = default!
    )
    {
        var result = await _activityManager.GetAssignmentDetails(AuditUserDetails, assignmentId, cancellationToken);
        return Ok(result);
    }

    /// <summary>
    /// Get the details of an assignment
    /// </summary>
    /// <param name="assignmentId"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    /// <exception cref="NotImplementedException"></exception>
    [Route("completeAssignment")]
    [AccessKey(SecurityAccess.ViewTasks)]
    [HttpPost]
    public async Task<IActionResult> CompleteAssignment([FromBody] PostAssignmentComplete completeAssignment, CancellationToken cancellationToken = default!
    )
    {
        throw new NotImplementedException();
        //var result = await _activityManager.GetAssignmentDetails(AuditUserDetails, assignmentId, cancellationToken);
        //return Ok(result);
    }

}