using FastEndpoints; using FrameworkBLL.UserVsDashboard; 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.UserVsDashboard { public class SaveUserVsDashboard : BaseEndpoint> { private readonly IUserVsDashboardBLL _UserVsDashboardBLL; public SaveUserVsDashboard(IUserVsDashboardBLL UserVsDashboardBLL) { _UserVsDashboardBLL = UserVsDashboardBLL; } public override void Configure() { Post("/UserVsDashboard/SaveUserVsDashboard"); AllowAnonymous(); } public record SaveUserVsDashboardParameters( [property: FromHeader] string Login, [property: FromBody] UserVsDashboardDTO UserVsDashboardDTO ); protected override string? GetCacheKey(SaveUserVsDashboardParameters req, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync(SaveUserVsDashboardParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _UserVsDashboardBLL.SaveUserVsDashboard(req.UserVsDashboardDTO, 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); } } } }