Beispiel #1
0
        /// <summary>
        /// Seed data into the table
        /// </summary>
        /// <param name="context">DbContext</param>
        public static void Seed(this TrappistDbContext context)
        {
            if (context.CodingLanguage.Any())
            {
                return;
            }

            var Languages = new CodingLanguage[]
            {
                new CodingLanguage {
                    Language = ProgrammingLanguage.Java.ToString()
                },
                new CodingLanguage {
                    Language = ProgrammingLanguage.Cpp.ToString()
                },
                new CodingLanguage {
                    Language = ProgrammingLanguage.C.ToString()
                }
            };

            foreach (CodingLanguage language in Languages)
            {
                context.CodingLanguage.Add(language);
            }

            context.SaveChanges();
        }
Beispiel #2
0
        public TestsRepository(TrappistDbContext dbContext, IGlobalUtil util, IStringConstants stringConstants, IConfiguration configuration)
        {
            _dbContext       = dbContext;
            _util            = util;
            _stringConstants = stringConstants;
            _configuration   = configuration;

            if (_configuration["EnableCache"] != null && Convert.ToBoolean(_configuration["EnableCache"]))
            {
                _enableCache = true;
            }
        }
Beispiel #3
0
        public TestConductRepository(TrappistDbContext dbContext
                                     , ITestsRepository testRepository
                                     , IConfiguration configuration
                                     , IQuestionRepository questionRepository
                                     , IStringConstants stringConstants
                                     , IHttpService httpService)
        {
            _dbContext          = dbContext;
            _testRepository     = testRepository;
            _questionRepository = questionRepository;
            _configuration      = configuration;
            _stringConstants    = stringConstants;
            _httpService        = httpService;

            if (_configuration["EnableCache"] != null && Convert.ToBoolean(_configuration["EnableCache"]))
            {
                _enableCache = true;
            }
        }
Beispiel #4
0
        public static void ClearDatabaseAndSeed(TrappistDbContext dbContext)
        {
            dbContext.Database.EnsureDeleted();
            //seed data will go here.
            var Languages = new CodingLanguage[]
            {
                new CodingLanguage {
                    Language = ProgrammingLanguage.Java.ToString()
                },
                new CodingLanguage {
                    Language = ProgrammingLanguage.Cpp.ToString()
                },
                new CodingLanguage {
                    Language = ProgrammingLanguage.C.ToString()
                }
            };

            foreach (CodingLanguage language in Languages)
            {
                dbContext.CodingLanguage.Add(language);
            }

            dbContext.SaveChanges();
        }
Beispiel #5
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, TrappistDbContext context, ConnectionString connectionString, IMemoryCache cache)
        {
            app.UseExceptionless(Configuration.GetSection("ExceptionlessKey").Value);

            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();



            if (env.IsDevelopment())
            {
                app.UseStaticFiles(new StaticFileOptions
                {
                    FileProvider = new PhysicalFileProvider(Path.GetFullPath(Path.Combine(env.ContentRootPath, "node_modules"))),
                    RequestPath  = new PathString("/node_modules")
                });
            }

            if (/*env.IsDevelopment()*/ true)
            {
                app.UseMiniProfiler();
            }

            app.UseAuthentication();
            app.UseSignalR(mapHub =>
            {
                mapHub.MapHub <TrappistHub>("TrappistHub");
            });

            app.UseSession();

            // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "pagenotfound",
                    template: "pagenotfound",
                    defaults: new { controller = "Home", action = "PageNotFound" });
                routes.MapRoute(
                    name: "conduct",
                    template: "conduct/{link?}/{route?}",
                    defaults: new { controller = "Home", action = "Conduct", route = "register" });
                routes.MapRoute(
                    name: "setup",
                    template: "setup",
                    defaults: new { controller = "Home", action = "Setup" });
                routes.MapRoute(
                    name: "login",
                    template: "login",
                    defaults: new { controller = "Account", action = "Login" });
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
                routes.MapSpaFallbackRoute(
                    name: "spa-fallback",
                    defaults: new { controller = "Home", action = "Index" });
            });

            if (!string.IsNullOrEmpty(connectionString.Value))
            {
                context.Database.Migrate();
                context.Seed();
            }
            #region Auto Mapper Configuration
            Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <CodeSnippetQuestionAC, CodeSnippetQuestion>()
                .ForMember(x => x.CodeSnippetQuestionTestCases, opts => opts.Ignore())
                .ReverseMap();
                cfg.CreateMap <SingleMultipleAnswerQuestionAC, SingleMultipleAnswerQuestion>().ForMember(x => x.SingleMultipleAnswerQuestionOption, opts => opts.Ignore()).ReverseMap();
                cfg.CreateMap <QuestionDetailAC, Question>().ReverseMap();
                cfg.CreateMap <QuestionAC, Question>().ReverseMap();
                cfg.CreateMap <Question, QuestionDetailAC>();
                cfg.CreateMap <SingleMultipleAnswerQuestion, SingleMultipleAnswerQuestionAC>();
                cfg.CreateMap <Category, CategoryAC>();
                cfg.CreateMap <CategoryAC, Category>();
                cfg.CreateMap <CodeSnippetQuestion, CodeSnippetQuestionAC>();
                cfg.CreateMap <Question, QuestionAC>();
                cfg.CreateMap <Test, TestAC>();
                cfg.CreateMap <TestAC, Test>();
                cfg.CreateMap <TestIpAddress, TestIpAddressAC>();
            });
            #endregion

            app.UseEFSecondLevelCache();
        }
Beispiel #6
0
 public ProfileRepository(TrappistDbContext dbContext, UserManager <ApplicationUser> userManager)
 {
     _dbContext   = dbContext;
     _userManager = userManager;
 }
 public QuestionsRepository(TrappistDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Beispiel #8
0
 public CategoryRepository(TrappistDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Beispiel #9
0
 public ReportRepository(TrappistDbContext dbContext, ITestConductRepository testConductRepository)
 {
     _dbContext             = dbContext;
     _testConductRepository = testConductRepository;
 }
Beispiel #10
0
 public BaseTest(Bootstrap bootstrap)
 {
     _scope             = bootstrap.ServiceProvider.CreateScope();
     _trappistDbContext = _scope.ServiceProvider.GetService <TrappistDbContext>();
     ClearDatabase.ClearDatabaseAndSeed(_trappistDbContext);
 }
Beispiel #11
0
 public DbUtility(TrappistDbContext trappistDbContext)
 {
     _trappistDbContext = trappistDbContext;
 }
Beispiel #12
0
 public TrappistHub(ITestConductRepository testConductRepository, TrappistDbContext dbContext)
 {
     _dbContext             = dbContext;
     _testConductRepository = testConductRepository;
 }