Spaces:
Sleeping
Sleeping
| using ECommerce.Model.Data; | |
| using ECommerce.Model.Repositories; | |
| using Microsoft.EntityFrameworkCore; | |
| using Microsoft.EntityFrameworkCore.Diagnostics; | |
| using Microsoft.Extensions.Configuration; | |
| using Microsoft.Extensions.DependencyInjection; | |
| namespace ECommerce.Model; | |
| public static class DependencyInjection | |
| { | |
| public static IServiceCollection AddModelLayer(this IServiceCollection services, IConfiguration config) | |
| { | |
| services.AddDbContext<AppDbContext>(options => | |
| options.UseNpgsql(config.GetConnectionString("DefaultConnection")) | |
| .ConfigureWarnings(w => w.Ignore(RelationalEventId.PendingModelChangesWarning))); | |
| services.AddScoped(typeof(IRepository<>), typeof(Repository<>)); | |
| services.AddScoped<ICustomerRepository, CustomerRepository>(); | |
| return services; | |
| } | |
| } | |