using BackOffice.BFF.WebApi.Common.Services; using BackOffice.BFF.Application.ConfigurationCQ.Commands.UpdateAppVersion; using BackOffice.BFF.Application.ConfigurationCQ.Queries.GetAllAppVersions; using BackOffice.BFF.Configuration.Protobuf.Protos.AppVersion; namespace BackOffice.BFF.WebApi.Services; public class AppVersionService : AppVersionContract.AppVersionContractBase { private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS; public AppVersionService(IDispatchRequestToCQRS dispatchRequestToCQRS) { _dispatchRequestToCQRS = dispatchRequestToCQRS; } [RequiresPermission(PermissionNames.SettingsView)] public override async Task GetAllAppVersions( GetAllAppVersionsRequest request, ServerCallContext context) { return await _dispatchRequestToCQRS.Handle( request, context); } [RequiresPermission(PermissionNames.SettingsView)] public override async Task GetAppVersion( GetAppVersionRequest request, ServerCallContext context) { // For single app version, we use GetAll and filter var allVersionsResponse = await _dispatchRequestToCQRS.Handle( new GetAllAppVersionsRequest { IncludeInactive = false }, context); var item = allVersionsResponse.Items.FirstOrDefault(x => x.AppName == request.AppName); return new GetAppVersionResponse { Found = item != null, Item = item }; } [RequiresPermission(PermissionNames.SettingsManageConfiguration)] public override async Task UpdateAppVersion( UpdateAppVersionRequest request, ServerCallContext context) { return await _dispatchRequestToCQRS.Handle( request, context); } }