using DMSBLL.Space; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace DMSSL.EndPoints.Space { public class DeleteSpace : BaseEndpoint> { private readonly ISpaceBLL _SpaceBLL; public DeleteSpace(ISpaceBLL SpaceBLL) { _SpaceBLL = SpaceBLL; } public override void Configure() { Delete("/Space/DeleteSpace"); AllowAnonymous(); } public record DeleteSpaceParameters( [property: FromHeader] string Login, [property: QueryParam] int SpaceId ); protected override async Task> ExecuteAsync(DeleteSpaceParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _SpaceBLL.DeleteSpace(req.SpaceId, LoginDTO!); 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); } } } }