40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using AutoMapper;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Portfolio.Application.Services.Articles;
|
|
using Portfolio.Application.Services.PokemonService;
|
|
using Portfolio.Domain.Features.Pokemon;
|
|
using Portfolio.Infrastructure.Repositories;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Portfolio.Infrastructure
|
|
{
|
|
public static class DependencyInjection
|
|
{
|
|
public static IServiceCollection AddInfrastructure( this IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
IMapper mapper = MappingConfig.RegisterMaps().CreateMapper();
|
|
|
|
|
|
|
|
services.AddDbContext<ApplicationDbContext>(options =>
|
|
options.UseSqlServer(configuration.GetConnectionString("DefaultConnection")
|
|
));
|
|
|
|
services.AddScoped<IPokemonRepository, PokemonRepository>();
|
|
|
|
|
|
services.AddSingleton(mapper);
|
|
services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
|
|
|
|
|
return services;
|
|
}
|
|
}
|
|
}
|