using EntitlementBLL.Legal; using FastEndpoints; using GB5Shared.Authorization; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace EntitlementSL.Endpoints.Legal; [MenuRights("entagree", RightOperation.Insert)] public class CreateDraftAgreementVersion : BaseEndpoint> { private readonly IAgreementAuthoringBLL _AuthoringBLL; public CreateDraftAgreementVersion(IAgreementAuthoringBLL authoringBLL) => _AuthoringBLL = authoringBLL; public override void Configure() { Post("/Legal/CreateDraftAgreementVersion"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: FromBody] Body Body ); public record Body(string TypeCode, string VersionLabel, string? JurisdictionCode, string? ContentRef, DateTime EffectiveFrom); protected override string? GetCacheKey(Params req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync(Params req, LoginDTO loginDTO, CancellationToken ct) { var result = await _AuthoringBLL.CreateDraftVersionAsync( req.Body.TypeCode, req.Body.VersionLabel, req.Body.JurisdictionCode, req.Body.ContentRef, req.Body.EffectiveFrom, loginDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, loginDTO); } }