using Core.Blueprint.Service.External.Clients; using Core.Blueprint.Service.External.Clients.BluePrintService; using Refit; namespace Core.Blueprint.Service.UseCases.BluePrint { public interface IBlueprintService { Task> GetBlueprintsAsync(); Task GetBlueprintAsync(string id); Task CreateBlueprintAsync(MongoBlueprintCollection blueprint); Task UpdateBlueprintAsync(string id, MongoBlueprintCollection blueprint); Task DeleteBlueprintAsync(string id); } public class BlueprintService: IBlueprintService { private readonly IBluePrintServiceClient _blueprintApi; public BlueprintService(IBluePrintServiceClient client) { _blueprintApi = client; } public async Task> GetBlueprintsAsync() { try { return await _blueprintApi.GetBlueprintsAsync(); } catch (ApiException ex) { Console.WriteLine($"Error fetching blueprints: {ex.Message}"); throw; } } public async Task GetBlueprintAsync(string id) { try { return await _blueprintApi.GetBlueprintAsync(id); } catch (ApiException ex) { Console.WriteLine($"Error fetching blueprint with ID {id}: {ex.Message}"); throw; } } public async Task CreateBlueprintAsync(MongoBlueprintCollection blueprint) { try { return await _blueprintApi.CreateBlueprintAsync(blueprint); } catch (ApiException ex) { Console.WriteLine($"Error creating blueprint: {ex.Message}"); throw; } } public async Task UpdateBlueprintAsync(string id, MongoBlueprintCollection blueprint) { try { await _blueprintApi.UpdateBlueprintAsync(id, blueprint); } catch (ApiException ex) { Console.WriteLine($"Error updating blueprint with ID {id}: {ex.Message}"); throw; } } public async Task DeleteBlueprintAsync(string id) { try { await _blueprintApi.DeleteBlueprintAsync(id); } catch (ApiException ex) { Console.WriteLine($"Error deleting blueprint with ID {id}: {ex.Message}"); throw; } } } }