-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74311eb
commit b4a3638
Showing
26 changed files
with
342 additions
and
259 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
Mensageria/Domain/Interfaces/IConfiguracaoParceiroRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Mensageria.Domain.Interfaces; | ||
|
||
public interface IConfiguracaoParceiroRepository | ||
{ | ||
Task<string> GetConnectionStringParceiroAsync(string referer); | ||
} |
10 changes: 10 additions & 0 deletions
10
Mensageria/Domain/Interfaces/IProdutosMaisVendidosRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Domain.Pkg.Entities; | ||
|
||
namespace Mensageria.Domain.Interfaces; | ||
|
||
public interface IProdutosMaisVendidosRepository | ||
{ | ||
Task AddRangeAsync(IList<ProdutosMaisVendidos> produtosMaisVendidos, string referer); | ||
Task UpdateRangeAsync(IList<ProdutosMaisVendidos> produtosMaisVendidos, string referer); | ||
Task<IList<ProdutosMaisVendidos>> GetProdutosMaisVendidosAsync(IList<Guid> produtosIds, string referer); | ||
} |
7 changes: 7 additions & 0 deletions
7
Mensageria/Dtos/ProdutosMaisVendidos/AddOrUpdateProdutosMaisVendidosDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Mensageria.Dtos.ProdutosMaisVendidos; | ||
|
||
public class AddOrUpdateProdutosMaisVendidosDto | ||
{ | ||
public Guid ProdutoId { get; set; } | ||
public decimal QuantidadeProdutos { get; set; } | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Domain.Pkg.Entities; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Mensageria.Infra.Context; | ||
|
||
public class OpenAdmContext(DbContextOptions<OpenAdmContext> options) | ||
: DbContext(options) | ||
{ | ||
public DbSet<Parceiro> Parceiros { get; set; } | ||
public DbSet<ConfiguracaoParceiro> ConfiguracoesParceiro { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Domain.Pkg.Entities; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Mensageria.Infra.Context; | ||
|
||
public class ParceiroContext(DbContextOptions options) | ||
: DbContext(options) | ||
{ | ||
public DbSet<Banner> Banners { get; set; } | ||
public DbSet<Funcionario> Funcionarios { get; set; } | ||
public DbSet<Categoria> Categorias { get; set; } | ||
public DbSet<Peso> Pesos { get; set; } | ||
public DbSet<Tamanho> Tamanhos { get; set; } | ||
public DbSet<Produto> Produtos { get; set; } | ||
public DbSet<PesosProdutos> PesosProdutos { get; set; } | ||
public DbSet<TamanhosProdutos> TamanhosProdutos { get; set; } | ||
public DbSet<Usuario> Usuarios { get; set; } | ||
public DbSet<Pedido> Pedidos { get; set; } | ||
public DbSet<ItensPedido> ItensPedidos { get; set; } | ||
public DbSet<TabelaDePreco> TabelaDePreco { get; set; } | ||
public DbSet<ItensTabelaDePreco> ItensTabelaDePreco { get; set; } | ||
public DbSet<ProdutosMaisVendidos> ProdutosMaisVendidos { get; set; } | ||
public DbSet<ConfiguracaoDeEmail> ConfiguracoesDeEmail { get; set; } | ||
public DbSet<ConfiguracoesDePedido> ConfiguracoesDePedidos { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Mensageria.Domain.Interfaces; | ||
using Mensageria.Infra.Context; | ||
using Mensageria.Infra.Interfaces; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Mensageria.Infra.Factories; | ||
|
||
public class FactoryParceiroContext : IFactoryParceiroContext | ||
{ | ||
private readonly IConfiguracaoParceiroRepository _configuracaoParceiroRepository; | ||
|
||
public FactoryParceiroContext(IConfiguracaoParceiroRepository configuracaoParceiroRepository) | ||
{ | ||
_configuracaoParceiroRepository = configuracaoParceiroRepository; | ||
} | ||
|
||
public async Task<ParceiroContext> CreateParceiroContextAsync(string referer) | ||
{ | ||
var connectionString = await _configuracaoParceiroRepository.GetConnectionStringParceiroAsync(referer); | ||
|
||
var optionsBuilderParceiro = new DbContextOptionsBuilder<ParceiroContext>(); | ||
|
||
optionsBuilderParceiro.UseNpgsql(connectionString); | ||
|
||
return new ParceiroContext(optionsBuilderParceiro.Options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Mensageria.Infra.Context; | ||
|
||
namespace Mensageria.Infra.Interfaces; | ||
|
||
public interface IFactoryParceiroContext | ||
{ | ||
Task<ParceiroContext> CreateParceiroContextAsync(string referer); | ||
} |
26 changes: 26 additions & 0 deletions
26
Mensageria/Infra/Repositories/ConfiguracaoParceiroRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Mensageria.Domain.Interfaces; | ||
using Mensageria.Infra.Context; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Mensageria.Infra.Repositories; | ||
|
||
public class ConfiguracaoParceiroRepository : IConfiguracaoParceiroRepository | ||
{ | ||
private readonly OpenAdmContext _openAdmContext; | ||
|
||
public ConfiguracaoParceiroRepository(OpenAdmContext openAdmContext) | ||
{ | ||
_openAdmContext = openAdmContext; | ||
} | ||
|
||
public async Task<string> GetConnectionStringParceiroAsync(string referer) | ||
{ | ||
return await _openAdmContext | ||
.ConfiguracoesParceiro | ||
.AsNoTracking() | ||
.Where(x => x.DominioSiteAdm == referer || x.DominioSiteEcommerce == referer) | ||
.Select(x => x.ConexaoDb) | ||
.FirstOrDefaultAsync() | ||
?? throw new Exception("Conexão do parceiro não foi localizada!"); | ||
} | ||
} |
Oops, something went wrong.