Add project files.

This commit is contained in:
Sergio Matias Urquin
2025-04-29 18:39:57 -06:00
parent 116793710f
commit 6358f5f199
110 changed files with 4484 additions and 0 deletions

View File

@@ -0,0 +1,125 @@
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;
}
}
}
}

View File

@@ -0,0 +1,22 @@
using Core.Blueprint.DAL.Infrastructure.Configure;
using Core.Blueprint.DAL.Service.Contracts;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace Core.Blueprint.DAL.Service.Configure
{
public static class DependencyInjection
{
public static IServiceCollection RegisterServices(this IServiceCollection services, IConfiguration configuration)
{
services.RegisterInfrastructure(configuration);
services.AddScoped<IBlueprintService, BlueprintService>();
services.AddScoped<ISampleItemService, SampleItemService>();
services.AddScoped<ISampleImageService, SampleImageService>();
services.AddScoped<ISecretService, SecretService>();
return services;
}
}
}

View File

@@ -0,0 +1,13 @@
using Core.Blueprint.Domain.Entities;
namespace Core.Blueprint.DAL.Service.Contracts
{
public interface IBlueprintService
{
ValueTask<BlueprintCollection> CreateAsync(BlueprintCollection entity);
ValueTask<bool> DeleteAsync(string id);
ValueTask<IEnumerable<BlueprintCollection>> GetAllAsync();
ValueTask<BlueprintCollection> GetByIdAsync(string id);
Task<bool> UpdateAsync(string id, BlueprintCollection entity);
}
}

View File

@@ -0,0 +1,11 @@
using Core.Blueprint.Domain.Dtos;
namespace Core.Blueprint.DAL.Service.Contracts
{
public interface ISampleImageService
{
IAsyncEnumerable<ImageUrlDto> GetAllUrl();
Task<ImageUrlDto> GetFirstUrl();
Task<ImageUrlDto> GetUploadUrl();
}
}

View File

@@ -0,0 +1,14 @@
using Core.Blueprint.Domain.Entities;
namespace Core.Blueprint.DAL.Service.Contracts
{
public interface ISampleItemService
{
ValueTask<SampleItem> CreateAsync(SampleItem entity);
ValueTask<bool> DeleteAsync(string id);
ValueTask<IEnumerable<SampleItem>> GetAllAsync();
ValueTask<SampleItem> GetByIdAsync(string id);
Task<bool> UpdateAsync(string id, SampleItem entity);
}
}

View File

@@ -0,0 +1,11 @@
using Core.Blueprint.Domain.Entities;
namespace Core.Blueprint.DAL.Service.Contracts
{
public interface ISecretService
{
Task<Secret> GetSecret(string secretName, CancellationToken cancellationToken);
Task SetSecret(string secretName, string secretValue, CancellationToken cancellationToken);
Task RemoveSecret(string secretName, CancellationToken cancellationToken);
}
}

View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Core.Blueprint.DAL.Infrastrcture\Core.Blueprint.DAL.Infrastructure.csproj" />
<ProjectReference Include="..\Core.Blueprint.Domain\Core.Blueprint.Domain.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,74 @@
using Core.Blueprint.DAL.Infrastructure.Contracts;
using Core.Blueprint.DAL.Service.Contracts;
using Core.Blueprint.Domain.Dtos;
using Serilog;
namespace Core.Blueprint.DAL.Service
{
public class SampleImageService : ISampleImageService
{
private readonly ISampleImageRepository _sampleImageRepository;
private readonly ILogger _logger;
public SampleImageService(ISampleImageRepository sampleImageRepository, ILogger logger)
{
_sampleImageRepository = sampleImageRepository;
_logger = logger;
}
public IAsyncEnumerable<ImageUrlDto> GetAllUrl()
{
try
{
_logger.Information("Starting to get the images urls list | Method: {method} | Class: {class}", nameof(GetAllUrl), nameof(SampleImageService));
var ret = _sampleImageRepository.GetAllImagesUrls();
_logger.Information("Finishing to get the images urls list | Method: {method} | Class: {class}", nameof(GetAllUrl), nameof(SampleImageService));
return ret;
}
catch (Exception ex)
{
_logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(GetAllUrl), nameof(SampleImageService));
return default;
}
}
public async Task<ImageUrlDto> GetFirstUrl()
{
try
{
_logger.Information("Starting to get the first image url | Method: {method} | Class: {class}", nameof(GetFirstUrl), nameof(SampleImageService));
var ret = await _sampleImageRepository.GetFirstImageUrl();
_logger.Information("Finishing to get the first image url | Method: {method} | Class: {class}", nameof(GetFirstUrl), nameof(SampleImageService));
return ret;
}
catch (Exception ex)
{
_logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(GetFirstUrl), nameof(SampleImageService));
return default;
}
}
public async Task<ImageUrlDto> GetUploadUrl()
{
try
{
_logger.Information("Starting to get the upload image url | Method: {method} | Class: {class}", nameof(GetUploadUrl), nameof(SampleImageService));
var ret = await _sampleImageRepository.GetUploadUrl();
_logger.Information("Finishing to get the upload image url | Method: {method} | Class: {class}", nameof(GetUploadUrl), nameof(SampleImageService));
return ret;
}
catch (Exception ex)
{
_logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(GetUploadUrl), nameof(SampleImageService));
return default;
}
}
}
}

View File

@@ -0,0 +1,114 @@
using Core.Blueprint.DAL.Infrastructure.Contracts;
using Core.Blueprint.DAL.Service.Contracts;
using Core.Blueprint.Domain.Entities;
using Serilog;
namespace Core.Blueprint.DAL.Service
{
//[LoggingAttribute]
public class SampleItemService : ISampleItemService
{
private readonly ILogger _logger;
private readonly IRepositoryIdentityBase<SampleItem> _repository;
public SampleItemService(ISampleItemRepository repository, ILogger logger)
{
_repository = repository;
_logger = logger;
}
//[LoggingAttribute] //Time of request, class name, class method... memory usage....
public virtual async ValueTask<SampleItem> CreateAsync(SampleItem entity)
{
try
{
_logger.Information("Starting to create the Sample item");
var ret = await _repository.CreateAsync(entity);
_logger.Information("Finishing to create the Sample item | Method: {method} | Class: {class}", nameof(CreateAsync), nameof(SampleItemService));
return ret;
}
catch (Exception ex)
{
_logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(CreateAsync), nameof(SampleItemService));
return default;
}
}
public virtual async ValueTask<bool> DeleteAsync(string id)
{
try
{
_logger.Information("Starting to delete the Sample item | Method: {method} | Class: {class}", nameof(DeleteAsync), nameof(SampleItemService));
var ret = await _repository.DeleteAsync(id);
_logger.Information("Finishing to delete the Sample item | Method: {method} | Class: {class}", nameof(DeleteAsync), nameof(SampleItemService));
return ret;
}
catch (Exception ex)
{
_logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(DeleteAsync), nameof(SampleItemService));
return default;
}
}
public virtual async ValueTask<IEnumerable<SampleItem>> GetAllAsync()
{
try
{
_logger.Information("Starting to get all Sample item | Method: {method} | Class: {class}", nameof(GetAllAsync), nameof(SampleItemService));
var ret = await _repository.GetAllAsync();
_logger.Information("Finishing to get all Sample item | Method: {method} | Class: {class}", nameof(GetAllAsync), nameof(SampleItemService));
return ret;
}
catch (Exception ex)
{
_logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(GetAllAsync), nameof(SampleItemService));
return default;
}
}
public virtual async ValueTask<SampleItem> GetByIdAsync(string id)
{
try
{
_logger.Information("Starting to get Sample item by id | Method: {method} | Class: {class}", nameof(GetByIdAsync), nameof(SampleItemService));
var ret = await _repository.GetByIdAsync(id);
_logger.Information("Finishing to get all Sample item | Method: {method} | Class: {class}", nameof(GetByIdAsync), nameof(SampleItemService));
return ret;
}
catch (Exception ex)
{
_logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(GetByIdAsync), nameof(SampleItemService));
return default;
}
}
public virtual async Task<bool> UpdateAsync(string id, SampleItem entity)
{
try
{
_logger.Information("Starting to update Sample item | Method: {method} | Class: {class}", nameof(UpdateAsync), nameof(SampleItemService));
var ret = await _repository.UpdateAsync(id, entity);
_logger.Information("Finishing to update Sample item | Method: {method} | Class: {class}", nameof(UpdateAsync), nameof(SampleItemService));
return ret;
}
catch (Exception ex)
{
_logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(UpdateAsync), nameof(SampleItemService));
return default;
}
}
}
}

View File

@@ -0,0 +1,76 @@
using Core.Blueprint.DAL.Infrastructure.Contracts;
using Core.Blueprint.DAL.Service.Contracts;
using Core.Blueprint.Domain.Entities;
using Serilog;
using SharpCompress.Common;
namespace Core.Blueprint.DAL.Service
{
public class SecretService : ISecretService
{
private readonly ISecretRepository _repository;
private readonly ILogger _logger;
public SecretService(ISecretRepository repository, ILogger logger)
{
_repository = repository;
_logger = logger;
}
public async Task<Secret> GetSecret(string secretName, CancellationToken cancellationToken)
{
try
{
_logger.Information("Starting to get the secret | Method: {method} | Class: {class}", nameof(GetSecret), nameof(SecretService));
var ret = await _repository.GetSecret(secretName, cancellationToken);
_logger.Information("Finishing to get the secret | Method: {method} | Class: {class}", nameof(GetSecret), nameof(SecretService));
return ret;
}
catch (Exception ex)
{
_logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(GetSecret), nameof(SecretService));
return default;
}
}
public async Task SetSecret(string secretName, string secretValue, CancellationToken cancellationToken)
{
try
{
_logger.Information("Starting to set the secret | Method: {method} | Class: {class}", nameof(SetSecret), nameof(SecretService));
await _repository.SetSecret(secretName, secretValue, cancellationToken);
_logger.Information("Finishing to set the secret | Method: {method} | Class: {class}", nameof(SetSecret), nameof(SecretService));
}
catch (Exception ex)
{
_logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(SetSecret), nameof(SecretService));
}
}
public async Task RemoveSecret(string secretName, CancellationToken cancellationToken)
{
try
{
_logger.Information("Starting to remove the secret | Method: {method} | Class: {class}", nameof(RemoveSecret), nameof(SecretService));
await _repository.RemoveSecret(secretName, cancellationToken);
_logger.Information("Finishing to remove the secret | Method: {method} | Class: {class}", nameof(RemoveSecret), nameof(SecretService));
}
catch (Exception ex)
{
_logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(RemoveSecret), nameof(SecretService));
}
}
}
}