コード例 #1
0
 public EntityBaseRepository(ExodusKoreaContext context,
                             IConfiguration config,
                             IOptions <AppSettings> appSettings)
 {
     _context     = context;
     _config      = config;
     _appSettings = appSettings.Value;
 }
コード例 #2
0
 public RankingRepository(ExodusKoreaContext context,
                          IConfiguration config,
                          IOptions <AppSettings> appSettings)
     : base(context, config, appSettings)
 {
     _context     = context;
     _config      = config;
     _appSettings = appSettings.Value;
 }
コード例 #3
0
 public VideoCommentReplyLikeRepository(ExodusKoreaContext context,
                                        IConfiguration config,
                                        IOptions <AppSettings> appSettings)
     : base(context, config, appSettings)
 {
     _context     = context;
     _config      = config;
     _appSettings = appSettings.Value;
 }
コード例 #4
0
 public MessageService(IHttpContextAccessor httpContextAccessor,
                       IConfiguration config,
                       IOptions <AppSettings> appSettings,
                       ExodusKoreaContext context)
 {
     _httpContextAccessor = httpContextAccessor;
     _config      = config;
     _appSettings = appSettings.Value;
     _context     = context;
 }
コード例 #5
0
        public LogDataService(IHttpContextAccessor httpContextAccessor,
                              IConfiguration config,
                              IClientIPService clientIP,
                              IMessageService email,
                              ExodusKoreaContext context)
        {
            _httpContextAccessor = httpContextAccessor;
            _config   = config;
            _clientIP = clientIP;
            _email    = email;
            _context  = context;

            HttpContext = _httpContextAccessor.HttpContext;
        }
コード例 #6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DbInitializer seeder, IAntiforgery antiforgery, IKotraNewsService kotra, IMemoryCache memoryCache, ExodusKoreaContext ekcontext)
        {
            // load kotra news in background and store in cache
            //foreach (var c in ekcontext.News)
            //{
            //    var cache = memoryCache.Get<List<KotraNewsVM>>(c.Topic);
            //    if (cache == null)
            //        kotra.GetKotraNewsByCountry(c.Topic);
            //}

            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
            JwtSecurityTokenHandler.DefaultOutboundClaimTypeMap.Clear();

            app.UseStaticFiles();

            app.UseCors(builder =>
            {
                if (_appSettingsEnv.Equals("Live"))
                {
                    builder.WithOrigins("https://talchoseon.com");
                }
                else if (_appSettingsEnv.Equals("Development"))
                {
                    builder.WithOrigins("http://localhost:4200");
                }
                builder.AllowAnyHeader();
                builder.AllowAnyMethod();
                builder.AllowCredentials();
            });

            app.UseExceptionHandler(builder =>
            {
                builder.Run(async context =>
                {
                    context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                    context.Response.Headers.Add("Access-Control-Allow-Origin", "*");

                    var error = context.Features.Get <IExceptionHandlerFeature>();
                    if (error != null)
                    {
                        //context.Response.AddApplicationError(error.Error.Message);
                        await context.Response.WriteAsync(error.Error.Message).ConfigureAwait(false);
                    }
                });
            });

            app.Use(next => context =>
            {
                if (context.Request.Path.Value.IndexOf("/", StringComparison.OrdinalIgnoreCase) != -1)
                {
                    var tokens = antiforgery.GetAndStoreTokens(context);
                    context.Response.Cookies.Append("XSRF-TOKEN", tokens.RequestToken, new CookieOptions()
                    {
                        HttpOnly = false
                    });
                }

                return(next(context));
            });

            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute("DefaultApi", "api/{controller}/{id?}");
            });

            app.UseWelcomePage();

            //seeder.InitializeData().Wait();
        }