Core.Blueprint.DAL/Core.Blueprint.DAL.Service/BlueprintService.cs
Sergio Matias Urquin 6358f5f199 Add project files.
2025-04-29 18:39:57 -06:00

126 lines
4.6 KiB
C#

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<BlueprintCollection> _repository;
public BlueprintService(IBlueprintRepository repository, ILogger logger)
{
_repository = repository;
_logger = logger;
}
public virtual async ValueTask<BlueprintCollection> 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<bool> 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<IEnumerable<BlueprintCollection>> 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<BlueprintCollection> 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<bool> 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;
}
}
}
}