using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MaintenanceBLL.ActivityType; using static GB5Shared.GB5Constant.Constant; namespace MaintenanceSL.FastEndPoints.ActivityType { public class GetActivityType : BaseEndpoint> { private readonly IActivityTypeBLL _activityTypeBLL; public GetActivityType(IActivityTypeBLL activityTypeBLL) { _activityTypeBLL = activityTypeBLL; } public override void Configure() { Get("/ActivityType/GetActivityType"); AllowAnonymous(); } public record GetActivityTypeParameters( [property: FromHeader] string Login, [property: QueryParam] int ActivityTypeId ); protected override async Task> ExecuteAsync(GetActivityTypeParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _activityTypeBLL.GetActivityType(req.ActivityTypeId, 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); } } } }