Add project
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Web.Data;
|
||||
using Web.Services;
|
||||
namespace Web.Extensions;
|
||||
|
||||
internal static class IServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddInternalServices(this IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<IOrdersService, OrdersService>();
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddDbAccess(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
string connectionString = configuration.GetConnectionString("DbContext")
|
||||
?? throw new InvalidOperationException("DB connection string is not set");
|
||||
services.AddDbContext<AppDbContext>(opts => opts.UseNpgsql(connectionString));
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user