using FastEndpoints; using FrameworkBLL.UserVsPortlet; using FrameworkDAL.DTO.User; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.UserVsPortlet { public class SaveUserVsPortlet : BaseEndpoint> { private readonly IUserVsPortletBLL _UserVsPortletBLL; public SaveUserVsPortlet(IUserVsPortletBLL UserVsPortletBLL) { _UserVsPortletBLL = UserVsPortletBLL; } public override void Configure() { Post("/UserVsPortlet/SaveUserVsPortlet"); AllowAnonymous(); } public record SaveUserVsPortletParameters( [property: FromHeader] string Login, [property: FromBody] List UserVsPortletDTO ); protected override async Task> ExecuteAsync(SaveUserVsPortletParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _UserVsPortletBLL.SaveUserVsPortlet(req.UserVsPortletDTO, 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); } } } }