// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <LibraryContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); // services.AddAutoMapper(); // we need this when we register maps via AutoMapper.Profile AutomapperConfig.Initialize(); OrderMapperConfig.Initialize(); services.AddMvc(options => { options.Filters.Add <ExceptionFilter>(); options.ReturnHttpNotAcceptable = true; }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .AddFluentValidation(fv => fv.RegisterValidatorsFromAssembly(GetType().Assembly)); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Rest API Learn", Version = "v1" }); }); services.AddSingleton(Mapper.Instance); services.AddScoped <ILibraryRepository, LibraryRepository>(); }
public OrderMapperConfigSetup() { OrderMapperConfig.Initialize(); }