using FastEndpoints; using FrameworkBLL.EntityRelation; using FrameworkDAL.DTO.Entity; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.EntityRelation { public class SaveEntityRelation : BaseEndpoint> { private readonly IEntityRelationBLL _EntityRelationBLL; public SaveEntityRelation(IEntityRelationBLL IEntityRelationBLL) { _EntityRelationBLL = IEntityRelationBLL; } public override void Configure() { Post("/EntityRelation/SaveEntityRelation"); AllowAnonymous(); } public record SaveEntityRelationParameters( [property: FromHeader] string Login, [property: FromBody] EntityRelationDTO EntityRelationDTO ); protected override async Task> ExecuteAsync(SaveEntityRelationParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _EntityRelationBLL.SaveEntityRelation(req.EntityRelationDTO, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NotRequired, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex,CacheKeyLevel.NotRequired,LoginDTO,ex.Message,500); } } } }