using FastEndpoints; using FrameworkBLL.Contact; using FrameworkSL.Endpoints.Contact; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.Contact { public class DeleteContact : BaseEndpoint> { private readonly IContactBLL _ContactBLL; public DeleteContact(IContactBLL IContactBLL) { _ContactBLL = IContactBLL; } public override void Configure() { Delete("/Contact/DeleteContact"); AllowAnonymous(); } public record DeleteContactParameters( [property: FromHeader] string Login, [property: QueryParam] int ContactId ); protected override async Task> ExecuteAsync(DeleteContactParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _ContactBLL.DeleteContact(req.ContactId, 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); } } } }