Exemple #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <RadixNotificationContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
            //services.AddMvc(options =>
            //{
            //    options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
            //});

            services.AddMvc();
            services.AddSingleton <IConfiguration>(Configuration);

            //Automapper Configuration
            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfileConfiguration());
            });
            var mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            RepositoryConfiguration.Configure(services);
            ServiceConfiguration.Configure(services);

            // DataTables.AspNet registration with default options.
            services.RegisterDataTables();
        }
Exemple #2
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc();
     services.AddDbContext <ClassroomSailorDbContext>(options =>
                                                      options.UseSqlServer(this.Configuration.GetConnectionString("Default")));
     services.AddScoped <ITeacherEntityFactory <TeacherApiModel>, TeacherEntityFactory <TeacherApiModel> >();
     services.AddScoped <IStudentEntityFactory <StudentApiModel>, StudentEntityFactory <StudentApiModel> >();
     services.AddScoped <IClassroomSailorUserService <StudentApiModel>, StudentService <StudentApiModel> >();
     services.AddScoped <IClassroomSailorUserService <TeacherApiModel>, TeacherService <TeacherApiModel> >();
     RepositoryConfiguration.Configure(services);
     ServiceConfiguration.Configure(services);
 }
Exemple #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //Automapper Configuration
            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });
            var mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            //Application Services and Repositories
            RepositoryConfiguration.Configure(services);
            ServiceConfigurations.Configure(services);

            services.AddDbContext <AllianzDBContext>(options =>
                                                     options.UseSqlServer(
                                                         Configuration.GetConnectionString("DefaultConnection")));
            services.AddIdentity <IdentityUser, IdentityRole>(options => options.SignIn.RequireConfirmedAccount = true)
            .AddEntityFrameworkStores <AllianzDBContext>();
            services.AddControllersWithViews();
            services.AddRazorPages();
        }
Exemple #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //Swagger Configuration
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "Cinema App Api", Description = "Swagger Cinema App Api"
                });
            });

            //Automapper Configuration
            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new MappingProfile());
            });
            var mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            //DataConfiguration
            services.AddDbContext <CinemaContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddSingleton <IJwtFactory, JwtFactory>();

            // jwt wire up
            // Get options from app settings
            var jwtAppSettingOptions = Configuration.GetSection(nameof(JwtIssuerOptions));

            // Configure JwtIssuerOptions
            services.Configure <JwtIssuerOptions>(options =>
            {
                options.Issuer             = jwtAppSettingOptions[nameof(JwtIssuerOptions.Issuer)];
                options.Audience           = jwtAppSettingOptions[nameof(JwtIssuerOptions.Audience)];
                options.SigningCredentials = new SigningCredentials(_signingKey, SecurityAlgorithms.HmacSha256);
            });

            // api user claim policy
            services.AddAuthorization(options =>
            {
                options.AddPolicy("ApiUser", policy => policy.RequireClaim(Constants.Strings.JwtClaimIdentifiers.Rol, Constants.Strings.JwtClaims.ApiAccess));
            });

            services.AddIdentity <AppUser, IdentityRole>
                (o =>
            {
                // configure identity options
                o.Password.RequireDigit           = false;
                o.Password.RequireLowercase       = false;
                o.Password.RequireUppercase       = false;
                o.Password.RequireNonAlphanumeric = false;
                o.Password.RequiredLength         = 6;
            })
            .AddEntityFrameworkStores <CinemaContext>()
            .AddDefaultTokenProviders();


            //Application Services and Repositories
            RepositoryConfiguration.Configure(services);
            ServiceConfiguration.Configure(services);

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

            services.AddMvc()
            .AddJsonOptions(
                options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                );

            // DataTables.AspNet registration with default options.
            services.RegisterDataTables();
        }