| 12345678910111213141516171819 |
- using RackPeek.Domain.Resources.Hardware.Models;
- namespace RackPeek.Domain.Resources.Hardware.Desktop;
- public class UpdateDesktopDriveUseCase(IHardwareRepository repository)
- {
- public async Task ExecuteAsync(string desktopName, int index, Drive updated)
- {
- var desktop = await repository.GetByNameAsync(desktopName) as Models.Desktop
- ?? throw new InvalidOperationException($"Desktop '{desktopName}' not found.");
- if (desktop.Drives == null || index < 0 || index >= desktop.Drives.Count)
- throw new InvalidOperationException($"Drive index {index} not found on desktop '{desktopName}'.");
- desktop.Drives[index] = updated;
- await repository.UpdateAsync(desktop);
- }
- }
|