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