using FastEndpoints; using FrameworkBLL.RoleVsPortlet; using FrameworkDAL.DTO.Portlet; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.RoleVsPortlet { public class SaveRoleVsPortlet : BaseEndpoint> { private readonly IRoleVsPortletBLL _RoleVsPortletBLL; public SaveRoleVsPortlet(IRoleVsPortletBLL RoleVsPortletBLL) { _RoleVsPortletBLL = RoleVsPortletBLL; } public override void Configure() { Post("/RoleVsPortlet/SaveRoleVsPortlet"); AllowAnonymous(); } public record SaveRoleVsPortletParameters( [property: FromHeader] string Login, [property: FromBody] RoleVsPortletDTO RoleVsPortletDTO ); protected override async Task> ExecuteAsync(SaveRoleVsPortletParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _RoleVsPortletBLL.SaveRoleVsPortlet(req.RoleVsPortletDTO, LoginDTO!); 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); } } } }