diff --git a/Marechai.App/Services/Client/SoundSynthsByMachine/SoundSynthsByMachineRequestBuilder.cs b/Marechai.App/Services/Client/SoundSynthsByMachine/SoundSynthsByMachineRequestBuilder.cs
index cd869b54..edeef6d3 100644
--- a/Marechai.App/Services/Client/SoundSynthsByMachine/SoundSynthsByMachineRequestBuilder.cs
+++ b/Marechai.App/Services/Client/SoundSynthsByMachine/SoundSynthsByMachineRequestBuilder.cs
@@ -2,6 +2,7 @@
#pragma warning disable CS0618
using Marechai.App.Models;
using Marechai.App.SoundSynthsByMachine.ByMachine;
+using Marechai.App.SoundSynthsByMachine.BySoundSynth;
using Marechai.App.SoundSynthsByMachine.Item;
using Microsoft.Kiota.Abstractions.Extensions;
using Microsoft.Kiota.Abstractions.Serialization;
@@ -24,6 +25,11 @@ namespace Marechai.App.SoundSynthsByMachine
{
get => new global::Marechai.App.SoundSynthsByMachine.ByMachine.ByMachineRequestBuilder(PathParameters, RequestAdapter);
}
+ /// The bySoundSynth property
+ public global::Marechai.App.SoundSynthsByMachine.BySoundSynth.BySoundSynthRequestBuilder BySoundSynth
+ {
+ get => new global::Marechai.App.SoundSynthsByMachine.BySoundSynth.BySoundSynthRequestBuilder(PathParameters, RequestAdapter);
+ }
/// Gets an item from the Marechai.App.soundSynthsByMachine.item collection
/// Unique identifier of the item
/// A
diff --git a/Marechai.App/Services/Client/kiota-lock.json b/Marechai.App/Services/Client/kiota-lock.json
index ac6e9cc0..c8d6ea80 100644
--- a/Marechai.App/Services/Client/kiota-lock.json
+++ b/Marechai.App/Services/Client/kiota-lock.json
@@ -1,5 +1,5 @@
{
- "descriptionHash": "B14C84F1E420D2432A615A20FD21AF1B4E0FD47B34883CFF5B5835650E46FB857B939E239BCAA0E48DDD88FC99AC6976E4263A5DBBCDDBDD7068E6F4A3D7FA74",
+ "descriptionHash": "C3420A48BBEE846A2606007719F2CB672783E54BFC6264E374C4EE4E7983D3F3D8505882D01625FF9C5A4C3A861D92FB482DCC66804B3CA76FD67E8E10717E5D",
"descriptionLocation": "http://localhost:5023/openapi/v1.json",
"lockFileVersion": "1.0.0",
"kiotaVersion": "1.29.0",
diff --git a/Marechai.App/Services/SoundSynthsService.cs b/Marechai.App/Services/SoundSynthsService.cs
new file mode 100644
index 00000000..03c31638
--- /dev/null
+++ b/Marechai.App/Services/SoundSynthsService.cs
@@ -0,0 +1,127 @@
+#nullable enable
+
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Marechai.App.Services;
+
+///
+/// Service for fetching and managing Sound Synthesizers from the Marechai API
+///
+public class SoundSynthsService
+{
+ private readonly ApiClient _apiClient;
+ private readonly ILogger _logger;
+
+ public SoundSynthsService(ApiClient apiClient, ILogger logger)
+ {
+ _apiClient = apiClient;
+ _logger = logger;
+ }
+
+ ///
+ /// Fetches all Sound Synthesizers from the API
+ ///
+ public async Task> GetAllSoundSynthsAsync()
+ {
+ try
+ {
+ _logger.LogInformation("Fetching all Sound Synthesizers from API");
+
+ List? soundSynths = await _apiClient.SoundSynths.GetAsync();
+
+ if(soundSynths == null) return [];
+
+ _logger.LogInformation("Successfully fetched {Count} total Sound Synthesizers", soundSynths.Count);
+
+ return soundSynths;
+ }
+ catch(Exception ex)
+ {
+ _logger.LogError(ex, "Error fetching all Sound Synthesizers from API");
+
+ return [];
+ }
+ }
+
+ ///
+ /// Fetches a single Sound Synthesizer by ID from the API
+ ///
+ public async Task GetSoundSynthByIdAsync(int soundSynthId)
+ {
+ try
+ {
+ _logger.LogInformation("Fetching Sound Synthesizer {SoundSynthId} from API", soundSynthId);
+
+ SoundSynthDto? soundSynth = await _apiClient.SoundSynths[soundSynthId].GetAsync();
+
+ if(soundSynth == null)
+ {
+ _logger.LogWarning("Sound Synthesizer {SoundSynthId} not found", soundSynthId);
+
+ return null;
+ }
+
+ _logger.LogInformation("Successfully fetched Sound Synthesizer {SoundSynthId}: {SoundSynthName}",
+ soundSynthId,
+ soundSynth.Name);
+
+ return soundSynth;
+ }
+ catch(Exception ex)
+ {
+ _logger.LogError(ex, "Error fetching Sound Synthesizer {SoundSynthId} from API", soundSynthId);
+
+ return null;
+ }
+ }
+
+ ///
+ /// Fetches machines that use a specific Sound Synthesizer
+ ///
+ public async Task> GetMachinesBySoundSynthAsync(int soundSynthId)
+ {
+ try
+ {
+ _logger.LogInformation("Fetching machines for Sound Synthesizer {SoundSynthId}", soundSynthId);
+
+ // Fetch from the sound-synths-by-machine/by-sound-synth/{soundSynthId} endpoint
+ List? soundSynthMachineRelationships =
+ await _apiClient.SoundSynthsByMachine.BySoundSynth[soundSynthId].GetAsync();
+
+ if(soundSynthMachineRelationships == null || soundSynthMachineRelationships.Count == 0) return [];
+
+ // Fetch full machine details for each to get Type information
+ var machines = new List();
+
+ foreach(SoundSynthByMachineDto sm in soundSynthMachineRelationships)
+ {
+ if(sm.MachineId.HasValue)
+ {
+ try
+ {
+ MachineDto? machine = await _apiClient.Machines[sm.MachineId.Value].GetAsync();
+ if(machine != null) machines.Add(machine);
+ }
+ catch(Exception ex)
+ {
+ _logger.LogWarning(ex, "Failed to fetch machine {MachineId}", sm.MachineId);
+ }
+ }
+ }
+
+ _logger.LogInformation("Successfully fetched {Count} machines for Sound Synthesizer {SoundSynthId}",
+ machines.Count,
+ soundSynthId);
+
+ return machines;
+ }
+ catch(Exception ex)
+ {
+ _logger.LogWarning(ex, "Error fetching machines for Sound Synthesizer {SoundSynthId}", soundSynthId);
+
+ return [];
+ }
+ }
+}
\ No newline at end of file
diff --git a/Marechai.Server/Controllers/SoundSynthsByMachineController.cs b/Marechai.Server/Controllers/SoundSynthsByMachineController.cs
index cf8303c1..703352f6 100644
--- a/Marechai.Server/Controllers/SoundSynthsByMachineController.cs
+++ b/Marechai.Server/Controllers/SoundSynthsByMachineController.cs
@@ -58,6 +58,24 @@ public class SoundSynthsByMachineController(MarechaiContext context) : Controlle
.ThenBy(g => g.Name)
.ToListAsync();
+ [HttpGet("by-sound-synth/{soundSynthId:int}")]
+ [AllowAnonymous]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
+ public Task> GetBySoundSynth(int soundSynthId) => context.SoundByMachine
+ .Where(g => g.SoundSynthId == soundSynthId)
+ .Select(g => new SoundSynthByMachineDto
+ {
+ Id = g.Id,
+ Name = g.Machine.Name,
+ CompanyName = g.Machine.Company.Name,
+ SoundSynthId = g.SoundSynthId,
+ MachineId = g.MachineId
+ })
+ .OrderBy(g => g.CompanyName)
+ .ThenBy(g => g.Name)
+ .ToListAsync();
+
[HttpDelete("{id:long}")]
[Authorize(Roles = "Admin,UberAdmin")]
[ProducesResponseType(StatusCodes.Status200OK)]