Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Brunobento1990 committed Jul 9, 2024
1 parent 03796a8 commit b4924c0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions OpenAdm.Application/Models/Produtos/ProdutoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ProdutoViewModel : BaseModel
public Guid CategoriaId { get; set; }
public CategoriaViewModel? Categoria { get; set; } = null!;
public string? Referencia { get; private set; }
public decimal? Peso { get; set; }
public ProdutoViewModel ToModel(Produto entity)
{
Foto = entity.UrlFoto;
Expand All @@ -41,6 +42,7 @@ public ProdutoViewModel ToModel(Produto entity)

CategoriaId = entity.CategoriaId;
Referencia = entity.Referencia;
Peso = entity.Peso;
return this;
}
}
36 changes: 36 additions & 0 deletions OpenAdm.Infra/Cached/Cached/ConfiguracaoParceiroCached.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Domain.Pkg.Entities;
using OpenAdm.Domain.Interfaces;
using OpenAdm.Infra.Cached.Interfaces;
using OpenAdm.Infra.Repositories;

namespace OpenAdm.Infra.Cached.Cached;

public sealed class ConfiguracaoParceiroCached : IConfiguracaoParceiroRepository
{
private readonly ConfiguracaoParceiroRepository _configuracaoParceiroRepository;
private readonly ICachedService<ConfiguracaoParceiro> _cachedService;

public ConfiguracaoParceiroCached(
ConfiguracaoParceiroRepository configuracaoParceiroRepository,
ICachedService<ConfiguracaoParceiro> cachedService)
{
_configuracaoParceiroRepository = configuracaoParceiroRepository;
_cachedService = cachedService;
}

public async Task<ConfiguracaoParceiro?> GetParceiroByDominioAdmAsync(string dominio)
{
var configuracaoParceiro = await _cachedService.GetItemAsync(dominio);

if(configuracaoParceiro == null)
{
configuracaoParceiro = await _configuracaoParceiroRepository.GetParceiroByDominioAdmAsync(dominio);
if(configuracaoParceiro != null)
{
await _cachedService.SetItemAsync(dominio, configuracaoParceiro);
}
}

return configuracaoParceiro;
}
}
4 changes: 3 additions & 1 deletion OpenAdm.IoC/DependencyInjectRepositories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public static void InjectRepositories(this IServiceCollection services, string c

services.AddTransient<IHttpContextAccessor, HttpContextAccessor>();

services.AddScoped<IConfiguracaoParceiroRepository, ConfiguracaoParceiroRepository>();
services.AddScoped<ConfiguracaoParceiroRepository>();
services.AddScoped<IConfiguracaoParceiroRepository, ConfiguracaoParceiroCached>();

services.AddScoped<ILoginUsuarioRepository, LoginUsuarioRepository>();
services.AddScoped<ICarrinhoRepository, CarrinhoRepository>();

Expand Down

0 comments on commit b4924c0

Please sign in to comment.