using EntitlementBLL.Interfaces; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using GB5Shared.Resource.Response; using static GB5Shared.GB5Constant.Constant; using GB5Shared.Authorization; namespace EntitlementSL.Endpoints.Subscription; [MenuRights("entsubscriptions", RightOperation.Update)] public class ChangePlan : BaseEndpoint> { private readonly ISubscriptionService _SubscriptionService; public ChangePlan(ISubscriptionService subscriptionService) => _SubscriptionService = subscriptionService; public override void Configure() { Post("/lic/Subscription.svc/ChangePlan"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: QueryParam] int SubscriptionId, [property: QueryParam] int NewPlanId ); protected override string? GetCacheKey(Params req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync(Params req, LoginDTO loginDTO, CancellationToken ct) { await _SubscriptionService.ChangePlanAsync(req.SubscriptionId, req.NewPlanId, loginDTO.UserId, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(SuccessResponse.UpdateSuccess, CacheKeyLevel.CLIENT_LEVEL, loginDTO); } }