using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using Microsoft.AspNetCore.Mvc; using RecruitmentBLL.ProfileGenerator; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.ProfileGenerator { public class DeleteProfileGenerator : BaseEndpoint> { private readonly IProfileGeneratorBLL _ProfileGeneratorBLL; public DeleteProfileGenerator(IProfileGeneratorBLL profileGeneratorBLL) { _ProfileGeneratorBLL = profileGeneratorBLL; } public override void Configure() { Delete("/ProfileGenerator/DeleteProfileGenerator"); AllowAnonymous(); } public record DeleteProfileGeneratorParameters( [property: FastEndpoints.FromHeader] string Login, [property: QueryParam] int ProfileGeneratorId ); // Mutation endpoint — no caching of Delete responses. protected override string? GetCacheKey(DeleteProfileGeneratorParameters req, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync( DeleteProfileGeneratorParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _ProfileGeneratorBLL .DeleteProfileGenerator(req.ProfileGeneratorId, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response .CreateSuccessResponse(result, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response .CreateExceptionError( ex, CacheKeyLevel.USER_LEVEL, LoginDTO, ex.Message, 500); } } } }