using FastEndpoints; using FrameworkBLL.RoleVsDashboard; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.RoleVsDashboard { public class GetUserVsDashboardForDeleteUserVsDashboard : BaseEndpoint> { private readonly IRoleVsDashboardBLL _RoleVsDashboardBLL; public GetUserVsDashboardForDeleteUserVsDashboard(IRoleVsDashboardBLL RoleVsDashboardBLL) { _RoleVsDashboardBLL = RoleVsDashboardBLL; } public override void Configure() { Get("/RoleVsDashboard/GetForDeleteUserVsDashboard"); AllowAnonymous(); } public record GetUserVsDashboardForDeleteUserVsDashboardParameters( [property: FromHeader] string Login, [property: QueryParam] int RoleId ); // "-for-delete" suffix is load-bearing — see GetRoleVsDashboardForUpdateUserVsDashboard's // identical comment: without a distinguishing suffix this collides with both // GetRoleVsDashboard and GetRoleVsDashboardForUpdateUserVsDashboard. protected override string? GetCacheKey(GetUserVsDashboardForDeleteUserVsDashboardParameters Parameters, LoginDTO LoginDTO) => KeyGenerator.KeyGeneration($"{Parameters.RoleId}-for-delete", EntityConstant.OBJECTROLEVSDASHBOARD, CacheKeyLevel.USER_LEVEL, LoginDTO); protected override async Task> ExecuteAsync(GetUserVsDashboardForDeleteUserVsDashboardParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _RoleVsDashboardBLL.GetUserVsDashboardForDeleteUserVsDashboard(req.RoleId, LoginDTO!, ct); 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); } } } }