43 lines
1.9 KiB
C#
43 lines
1.9 KiB
C#
|
|
using Meezi.Core.Interfaces;
|
||
|
|
using Meezi.Infrastructure.Data;
|
||
|
|
using Meezi.Infrastructure.ExternalServices;
|
||
|
|
using Meezi.Infrastructure.Services;
|
||
|
|
using Meezi.Infrastructure.Services.Platform;
|
||
|
|
using Microsoft.EntityFrameworkCore;
|
||
|
|
using Microsoft.Extensions.Caching.Memory;
|
||
|
|
using Microsoft.Extensions.Configuration;
|
||
|
|
using Microsoft.Extensions.DependencyInjection;
|
||
|
|
|
||
|
|
namespace Meezi.Infrastructure;
|
||
|
|
|
||
|
|
public static class DependencyInjection
|
||
|
|
{
|
||
|
|
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
|
||
|
|
{
|
||
|
|
var connectionString = configuration.GetConnectionString("DefaultConnection")
|
||
|
|
?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
|
||
|
|
|
||
|
|
services.AddDbContext<AppDbContext>(options =>
|
||
|
|
options.UseNpgsql(connectionString));
|
||
|
|
|
||
|
|
services.AddScoped<TenantContext>();
|
||
|
|
services.AddScoped<ITenantContext>(sp => sp.GetRequiredService<TenantContext>());
|
||
|
|
services.AddScoped<BranchContext>();
|
||
|
|
services.AddScoped<IBranchContext>(sp => sp.GetRequiredService<BranchContext>());
|
||
|
|
services.AddScoped<IPlatformRuntimeConfig, PlatformRuntimeConfig>();
|
||
|
|
services.AddMemoryCache();
|
||
|
|
services.AddScoped<IPlatformCatalogService, PlatformCatalogService>();
|
||
|
|
services.AddScoped<ISupportTicketService, SupportTicketService>();
|
||
|
|
|
||
|
|
services.AddHttpClient<ISmsService, KavenegarSmsService>();
|
||
|
|
services.AddHttpClient<IZarinPalGateway, ZarinPalGateway>();
|
||
|
|
services.AddHttpClient<ISnappPayGateway, SnappPayGateway>();
|
||
|
|
services.AddHttpClient<ITaraPaymentGateway, TaraPaymentGateway>();
|
||
|
|
services.AddHttpClient<ISnappfoodClient, SnappfoodClient>();
|
||
|
|
services.AddHttpClient<ITap30Client, Tap30Client>();
|
||
|
|
services.AddScoped<ITarazTaxService, TarazTaxService>();
|
||
|
|
|
||
|
|
return services;
|
||
|
|
}
|
||
|
|
}
|