using FastEndpoints; using GB5Shared.PushNotification; using GB5Shared.DTO.PushNotification; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static FrameworkDAL.Constant.Constant; namespace FrameworkSL.Endpoints.PushNotification { public class SaveUserTokenAsync : BaseEndpoint> { private readonly IPushNotificationBLL PushNotificationBLL; public SaveUserTokenAsync(IPushNotificationBLL IPushNotificationBLL) { PushNotificationBLL = IPushNotificationBLL; } public override void Configure() { Get("/PushNotification/SaveUserTokenAsync"); AllowAnonymous(); } public record SaveUserTokenAsyncParameters( [property: FromHeader] string Login, [property: QueryParam] string Token ); protected override async Task> ExecuteAsync(SaveUserTokenAsyncParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await PushNotificationBLL.SaveUserToken(LoginDTO, req.Token); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NotRequired, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NotRequired, LoginDTO, ex.Message, 500); } } } }