Example #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, WOFContext wofContext)
        {
            // add NLog
            //loggerFactory.AddProvider(new NLog.Extensions.Logging.NLogLoggerProvider);
            loggerFactory.ConfigureNLog("nlog.config");
            loggerFactory.AddNLog();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseWebpackDevMiddleware(new Microsoft.AspNetCore.SpaServices.Webpack.WebpackDevMiddlewareOptions
                {
                    HotModuleReplacement = true
                });
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }
            // Auto Create Seed Data if no data created yet
            wofContext.EnsureSeedDataForContext();

            app.UseStatusCodePages();

            // Give access to static file like css, js, etc
            app.UseStaticFiles();

            // Init Mapping for Converting Entity to Model(Dto)
            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Prize, PrizeDto>();
                cfg.CreateMap <Prize, PrizeForUpdateDto>();
                cfg.CreateMap <Prize, PrizeForCreateDto>();
                cfg.CreateMap <PrizeForUpdateDto, Prize>();
                cfg.CreateMap <PrizeForCreateDto, Prize>();
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}");

                routes.MapSpaFallbackRoute(
                    name: "spa-fallback",
                    defaults: new { controller = "Home", action = "Index" });
            });
        }
Example #2
0
 public PrizeRepository(WOFContext wofContext)
 {
     _wofContext = wofContext;
 }