using CRMBLL.Action; using CRMDAL.DTO.Action; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace CRMSL.EndPoints.Action { public class UpdateActivity : BaseEndpoint> { private readonly IActionBLL _ActionBLL; public UpdateActivity(IActionBLL ActionBLL) => _ActionBLL = ActionBLL; public override void Configure() { Put("/Action/UpdateActivity"); AllowAnonymous(); } public record Parameters( [property: FromHeader] string Login, [property: FromBody] SelectionActionDTO SelectionActionDTO ); protected override string? GetCacheKey(Parameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( Parameters req, LoginDTO LoginDTO, CancellationToken ct) { try { if (req.SelectionActionDTO == null) throw new ArgumentNullException(nameof(req.SelectionActionDTO), "Selection action data is required."); if (req.SelectionActionDTO.ActionId <= 0) throw new ArgumentException("ActionId is required."); if (req.SelectionActionDTO.ActionDetailId <= 0) throw new ArgumentException("ActionDetailId is required."); var result = await _ActionBLL.UpdateActivity(req.SelectionActionDTO, 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); } } } }