diff --git a/backend/api/Services/MissionLoaders/EchoAndCustomMissionLoader.cs b/backend/api/Services/MissionLoaders/EchoAndCustomMissionLoader.cs new file mode 100644 index 00000000..a62f0ebd --- /dev/null +++ b/backend/api/Services/MissionLoaders/EchoAndCustomMissionLoader.cs @@ -0,0 +1,37 @@ +using Api.Controllers.Models; +using Api.Database.Models; +namespace Api.Services.MissionLoaders +{ + public class EchoAndCustomMissionLoader( + IEchoService echoService, + ISourceService sourceService) : IMissionLoader + { + public async Task> GetAvailableMissions(string? installationCode) + { + return await echoService.GetAvailableMissions(installationCode); + } + + public async Task GetMissionById(string sourceMissionId) + { + return await echoService.GetMissionById(sourceMissionId); + } + + public async Task> GetTasksForMission(string missionSourceId) + { + var customMissionTasks = await sourceService.GetMissionTasksFromSourceId(missionSourceId); + if (customMissionTasks != null) + { + return customMissionTasks; + } + else + { + return await echoService.GetTasksForMission(missionSourceId); + } + } + + public async Task> GetPlantInfos() + { + return await echoService.GetPlantInfos(); + } + } +} diff --git a/backend/api/Services/SourceService.cs b/backend/api/Services/SourceService.cs index cd46fa32..2ddf3152 100644 --- a/backend/api/Services/SourceService.cs +++ b/backend/api/Services/SourceService.cs @@ -20,6 +20,8 @@ public interface ISourceService public abstract Task CreateSourceIfDoesNotExist(List tasks, bool readOnly = true); + public abstract Task?> GetMissionTasksFromSourceId(string id); + public abstract Task Delete(string id); public void DetachTracking(Source source); diff --git a/backend/api/appsettings.json b/backend/api/appsettings.json index 020e07ff..7055edc3 100644 --- a/backend/api/appsettings.json +++ b/backend/api/appsettings.json @@ -36,7 +36,7 @@ "ConnectionString": "" }, "MissionLoader": { - "FileName": "Api.Services.MissionLoaders.EchoMissionLoader" + "FileName": "Api.Services.MissionLoaders.EchoAndCustomMissionLoader" }, "KeyVault": { "UseKeyVault": true