using DMSBLL.Project; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace DMSSL.EndPoints.Project { public class GetProject : BaseEndpoint { private readonly IProjectBLL _ProjectBLL; public GetProject(IProjectBLL IProjectBLL) { _ProjectBLL = IProjectBLL; } public override void Configure() { Get("/Project/GetProject"); AllowAnonymous(); } public record GetProjectParameters( [property: QueryParam] int SpaceProjectId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetProjectParameters GetProjectParameters, LoginDTO LoginDTO) { try { return KeyGenerator.KeyGeneration(GetProjectParameters.SpaceProjectId!, EntityConstant.OBJECTSPACEPROJECT, CacheKeyLevel.USER_LEVEL, LoginDTO); } catch (Exception) { throw; } } protected override async Task> ExecuteAsync(GetProjectParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _ProjectBLL.GetProject(req.SpaceProjectId, 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); } } } }