using FastEndpoints; using FrameworkBLL.RoleVsPortlet; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.RoleVsPortlet { public class GetRoleVsPortletForUpdateUserVsPortlet : BaseEndpoint> { private readonly IRoleVsPortletBLL _RoleVsPortletBLL; public GetRoleVsPortletForUpdateUserVsPortlet(IRoleVsPortletBLL IRoleVsPortletBLL) { _RoleVsPortletBLL = IRoleVsPortletBLL; } public override void Configure() { Get("/RoleVsPortlet/GetForUpdateUserVsPortlet"); AllowAnonymous(); } public record GetRoleVsPortletForUpdateUserVsPortletParameters( [property: FromHeader] string Login, [property: QueryParam] int RoleId ); protected override string? GetCacheKey(GetRoleVsPortletForUpdateUserVsPortletParameters Parameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(Parameters.RoleId!, EntityConstant.OBJECTROLEVSPORTLET, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetRoleVsPortletForUpdateUserVsPortletParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _RoleVsPortletBLL.GetRoleVsPortletForUpdateUserVsPortlet(req.RoleId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.USER_LEVEL, LoginDTO, ex.Message, 500); } } } }