using FastEndpoints; using FrameworkBLL.Contact; using FrameworkDAL.DTO.Address; 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 SaveContact : BaseEndpoint> { private readonly IContactBLL _ContactBLL; public SaveContact(IContactBLL ContactBLL) { _ContactBLL = ContactBLL; } public override void Configure() { Post("/Contact/SaveContact"); AllowAnonymous(); } public record SaveContactParameters( [property: FromHeader] string Login, [property: FromBody] ContactDTO ContactDTO ); protected override async Task> ExecuteAsync(SaveContactParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _ContactBLL.SaveContact(req.ContactDTO, 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); } } } }