using Core.Blueprint.DAL.Infrastructure.Contracts; using Core.Blueprint.DAL.Service.Contracts; using Core.Blueprint.Domain.Entities; using Microsoft.AspNetCore.Http.HttpResults; using Serilog; namespace Core.Blueprint.DAL.Service { public class BlueprintService : IBlueprintService { private readonly ILogger _logger; private readonly IRepositoryIdentityBase _repository; public BlueprintService(IBlueprintRepository repository, ILogger logger) { _repository = repository; _logger = logger; } public virtual async ValueTask CreateAsync(BlueprintCollection entity) { try { _logger.Information("Start to create the BluePrintCollection | Method: {method} | Class: {class}", nameof(CreateAsync), nameof(BlueprintService)); var ret = await _repository.CreateAsync(entity); _logger.Information("The blueprint collection was created | Method: {method} | Class: {class}", nameof(CreateAsync), nameof(BlueprintService)); return ret; } catch (Exception ex) { _logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(CreateAsync), nameof(BlueprintService)); return default; } } public virtual async ValueTask DeleteAsync(string id) { try { _logger.Information("Start to delete BluePrintCollection | Method: {method} | Class: {class}", nameof(DeleteAsync), nameof(BlueprintService)); var ret = await _repository.DeleteAsync(id); _logger.Information("The blueprintcollection delete Finished | Method: {method} | Class: {class}", nameof(DeleteAsync), nameof(BlueprintService)); return ret; } catch (Exception ex) { _logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(DeleteAsync), nameof(BlueprintService)); return default; } } public virtual async ValueTask> GetAllAsync() { try { _logger.Information("Start to get the BluePrintCollection list | Method: {method} | Class: {class}", nameof(GetAllAsync), nameof(BlueprintService)); var ret = await _repository.GetAllAsync(); _logger.Information("The get blueprintcollection list Finished | Method: {method} | Class: {class}", nameof(GetAllAsync), nameof(BlueprintService)); return ret; } catch (Exception ex) { _logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(GetAllAsync), nameof(BlueprintService)); return default; } } public virtual async ValueTask GetByIdAsync(string id) { try { _logger.Information("Start to get a sigle BluePrintCollection | Method: {method} | Class: {class}", nameof(GetByIdAsync), nameof(BlueprintService)); var ret = await _repository.GetByIdAsync(id); _logger.Information("The single blueprintcollection got | Method: {method} | Class: {class}", nameof(GetByIdAsync), nameof(BlueprintService)); return ret; } catch (Exception ex) { _logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(GetByIdAsync), nameof(BlueprintService)); return default; } } public virtual async Task UpdateAsync(string id, BlueprintCollection entity) { try { _logger.Information("Start to update BluePrintCollection | Method: {method} | Class: {class}", nameof(UpdateAsync), nameof(BlueprintService)); var ret = await _repository.UpdateAsync(id, entity); _logger.Information("The blueprintcollection update Finished | Method: {method} | Class: {class}", nameof(UpdateAsync), nameof(BlueprintService)); return ret; } catch (Exception ex) { _logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(UpdateAsync), nameof(BlueprintService)); return default; } } } }