using FastEndpoints; using FrameworkBLL.RoleVsDashboard; using FrameworkDAL.DTO.Dashboard; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.RoleVsDashboard { public class SaveRoleVsDashboard : BaseEndpoint> { private readonly IRoleVsDashboardBLL _RoleVsDashboardBLL; public SaveRoleVsDashboard(IRoleVsDashboardBLL RoleVsDashboardBLL) { _RoleVsDashboardBLL = RoleVsDashboardBLL; } public override void Configure() { Post("/RoleVsDashboard/SaveRoleVsDashboard"); AllowAnonymous(); } public record SaveRoleVsDashboardParameters( [property: FromHeader] string Login, [property: FromBody] RoleVsDashboardDTO RoleVsDashboardDTO ); protected override string? GetCacheKey(SaveRoleVsDashboardParameters req, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync(SaveRoleVsDashboardParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _RoleVsDashboardBLL.SaveRoleVsDashboard(req.RoleVsDashboardDTO, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }