using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MarketingBLL.LeadSource; using MarketingDAL.DTO.LeadSource; using static GB5Shared.GB5Constant.Constant; namespace MarketingSL.EndPoints.LeadSource { public class SaveLeadSource : BaseEndpoint { private readonly ILeadSourceBLL _LeadSourceBLL; public SaveLeadSource(ILeadSourceBLL LeadSourceBLL) { _LeadSourceBLL = LeadSourceBLL; } public override void Configure() { Post("/LeadSource/SaveLeadSource"); AllowAnonymous(); } public record SaveLeadSourceParameters( [property: FromBody] LeadSourceDTO LeadSourceDTO, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync(SaveLeadSourceParameters parameters, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _LeadSourceBLL.SaveLeadSource(parameters.LeadSourceDTO, 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); } } } }