using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MarketingBLL.GrowthPlay; using MarketingDAL.DTO.GrowthPlay; using static GB5Shared.GB5Constant.Constant; namespace MarketingSL.EndPoints.GrowthPlay; public class SaveGrowthPlay : BaseEndpoint> { private readonly IGrowthPlayBLL _GrowthPlayBLL; public SaveGrowthPlay(IGrowthPlayBLL growthPlayBLL) => _GrowthPlayBLL = growthPlayBLL; public override void Configure() { Post("/GrowthPlay/SaveGrowthPlay"); AllowAnonymous(); } public record SaveGrowthPlayParameters( [property: FromHeader] string Login, [property: FromBody] GrowthPlayDTO GrowthPlayDTO ); protected override string? GetCacheKey(SaveGrowthPlayParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync(SaveGrowthPlayParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _GrowthPlayBLL.SaveGrowthPlay(req.GrowthPlayDTO, login!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } }