using System;
using System.Threading.Tasks;
using FrameworkBLL.GOP;
using GB5Shared.DTO.Framework.Login;
using GB5Shared.DTO.Framework.ResponseStandard;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using static GB5Shared.GB5Constant.Constant;
namespace FrameworkSL.Controllers.GOP
{
///
/// GOP Flow Management
/// Read-only endpoints for browsing source bindings, snapshots, and snapshot steps.
///
[ApiController]
[Route("[controller]")]
public class GopFlowService : ControllerBase
{
private readonly IGopFlowBLL _IGopFlowBLL;
public GopFlowService(IGopFlowBLL IGopFlowBLL)
{
_IGopFlowBLL = IGopFlowBLL;
}
/// Returns all active source bindings for the client.
[HttpGet("GetAllSourceBindings")]
public async Task> GetAllSourceBindings(
[FromHeader(Name = "Login")] string LoginDTOJson)
{
var LoginDTO = JsonConvert.DeserializeObject(LoginDTOJson);
try
{
var result = await _IGopFlowBLL.GetAllSourceBindings(LoginDTO!);
return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(
result, CacheKeyLevel.NOT_REQUIRED, LoginDTO!);
}
catch (Exception ex)
{
return await GB5Shared.ResponseStandard.Response.CreateExceptionError(
ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO!, ex.Message, 500);
}
}
/// Returns the snapshot header for a specific flow + version.
[HttpGet("GetFlowSnapshot")]
public async Task> GetFlowSnapshot(
int FlowId,
string SnapshotVersion,
[FromHeader(Name = "Login")] string LoginDTOJson)
{
var LoginDTO = JsonConvert.DeserializeObject(LoginDTOJson);
try
{
var result = await _IGopFlowBLL.GetFlowSnapshot(FlowId, SnapshotVersion, LoginDTO!);
return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(
result, CacheKeyLevel.NOT_REQUIRED, LoginDTO!);
}
catch (Exception ex)
{
return await GB5Shared.ResponseStandard.Response.CreateExceptionError(
ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO!, ex.Message, 500);
}
}
/// Returns all ordered steps for a snapshot version.
[HttpGet("GetSnapshotSteps")]
public async Task> GetSnapshotSteps(
string SnapshotVersion,
[FromHeader(Name = "Login")] string LoginDTOJson)
{
var LoginDTO = JsonConvert.DeserializeObject(LoginDTOJson);
try
{
var result = await _IGopFlowBLL.GetSnapshotSteps(SnapshotVersion, LoginDTO!);
return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(
result, CacheKeyLevel.NOT_REQUIRED, LoginDTO!);
}
catch (Exception ex)
{
return await GB5Shared.ResponseStandard.Response.CreateExceptionError(
ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO!, ex.Message, 500);
}
}
}
}