using AipGateway.API.Application; using AipGateway.API.Application.Interfaces.Services; using AipGateway.API.Domain.Exceptions; using AipGateway.API.Domain.IRepositories.IGenericRepositories; using AipGateway.API.Domain.Models.Dto; using AipGateway.API.Domain.Models.Response; using AipGateway.API.Repositories; using AipGateway.API.Services.Interfaces; using AutoMapper; namespace AipGateway.API.Services { public class ApiDbService : BaseService, IApiDbService { private readonly ILogger _log; private readonly IApiAuthService _apiAuthService; private readonly IAipDbRepository _repo; public ApiDbService(ILogger log, IAipFileService aipFileService, IApiAuthService apiAuthService, IAipDbRepository repo) : base(aipFileService) { _log = log; _apiAuthService = apiAuthService; _repo = repo; } public async Task ReloadDatabase() { try { var task = Task.Run(() => { int result = _apiAuthService.LoadAuthInformation(); return result; }); int result = await task; return new GeneralResponse { errorCode = 0, errorMessage = GlobalConstants.API_RESULT_SUCCESS, effectCount = result, }; } catch (Exception) { throw; } } public async Task> GetLinkedSystems() { try { var result = await _repo.GetLinkedSystems(); return result; } catch (Exception) { throw; } } public async Task> GetLinkedServers() { try { var result = await _repo.GetLinkedServers(); return result; } catch (Exception) { throw; } } public async Task> GetLinkedApiKeys() { try { var result = await _repo.GetLinkedApiKeys(); return result; } catch (Exception) { throw; } } public async Task> GetLinkedDecryptKeys() { try { var result = await _repo.GetLinkedDecryptKeys(); return result; } catch (Exception) { throw; } } } }