public static IServiceCollection AddDependencyInjection(this IServiceCollection services)
        {
            var repositoryDependencyInjection = new RepositoryDependencyInjection(services);

            repositoryDependencyInjection.AddServices();

            return(services);
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <AppDbContext> (options => {
                options.UseSqlServer(DabaseConnectionConfiguration.ConnectionString,
                                     opt => {
                    opt.MaxBatchSize(1000);
                });
            });

            ConfigureAPIVersioning(services);

            services.AddSwaggerGen(c => {
                c.SwaggerDoc("v1",
                             new Swashbuckle.AspNetCore.Swagger.Info {
                    Version = "v1",
                    Title   = "Portal API",
                });

                c.AddSecurityDefinition(
                    "Bearer",
                    new ApiKeyScheme {
                    In          = "header",
                    Description = "Autenticação baseada em Json Web Token (JWT)",
                    Name        = "Authorization",
                    Type        = "apiKey",
                });

                c.AddSecurityRequirement(new Dictionary <string, IEnumerable <string> > {
                    { "Bearer", new string[] { } }
                });
            });

            ConfigureAuthentication(services);

            RepositoryDependencyInjection.ConfigureServices(services);
            BusinessLogicDependencyInjection.ConfigureServices(services);

            services.AddCors(options => {
                options.AddPolicy("AllowAll",
                                  builder => {
                    builder
                    .AllowAnyOrigin()
                    .AllowAnyMethod()
                    .AllowAnyHeader()
                    .AllowCredentials();
                });
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }
Exemplo n.º 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(
                                                             Configuration.GetConnectionString("LeaveManagementDBConnection")));
            services.AddDefaultIdentity <IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
            .AddEntityFrameworkStores <ApplicationDbContext>();

            //Inject reporsitory services here
            RepositoryDependencyInjection.InjectRepositories(services);

            services.AddAutoMapper(typeof(MyAutoMapper));

            services.AddControllersWithViews();
            services.AddRazorPages();
        }