using FastEndpoints; using FMBLL.AssetType; using FMDAL.DTO.AssetType; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FMSL.EndPoints.AssetType { public class SaveAssetType : BaseEndpoint> { private readonly IAssetTypeBLL _AssetTypeBLL; public SaveAssetType(IAssetTypeBLL AssetTypeBLL) { _AssetTypeBLL = AssetTypeBLL; } public override void Configure() { Post("/AssetType/SaveAssetType"); AllowAnonymous(); } public record SaveAssetTypeParameters( [property: FromHeader] string Login, [property: FromBody] AssetTypeDTO AssetTypeDTO ); protected override async Task> ExecuteAsync(SaveAssetTypeParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _AssetTypeBLL.SaveAssetType(req.AssetTypeDTO, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.USER_LEVEL, LoginDTO, ex.Message, 500); } } } }