using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MaintenanceBLL.ActivityType; using MaintenanceDAL.DTO.ActivityType; using Microsoft.AspNetCore.Authorization; using static GB5Shared.GB5Constant.Constant; namespace MaintenanceSL.FastEndPoints.ActivityType { public class SaveActivityType: BaseEndpoint { private IActivityTypeBLL _ActivityTypeBLL; public SaveActivityType(IActivityTypeBLL ActivityTypeBLL) { _ActivityTypeBLL = ActivityTypeBLL; } public override void Configure() { Post("/ActivityType/SaveActivityType"); AllowAnonymous(); } public record SaveActivityTypeParameters( [property: FromBody] ActivityTypeDTO ActivityTypeDTO, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync(SaveActivityTypeParameters Parameters, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _ActivityTypeBLL.SaveActivityType(Parameters.ActivityTypeDTO, 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); } } } }