Beispiel #1
0
        public static void CreateSeedData(this QuestionTypeDBContext context)
        {
            if (context.QuestionsTypes.Any())
            {
                return;
            }
            var questionsType = new List <QuestionType>()
            {
                new QuestionType()
                {
                    Question_Type_Name = "number",
                },
                new QuestionType()
                {
                    Question_Type_Name = "multiple_option",
                },
                new QuestionType()
                {
                    Question_Type_Name = "single_option",
                },
                new QuestionType()
                {
                    Question_Type_Name = "text",
                },
            };

            context.AddRange(questionsType);
            context.SaveChanges();
        }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app,
            IHostingEnvironment env,
            SurveyDBContext surveyDBContext,
            QuestionTypeDBContext questionTypeDBContext,
            UserDBContext userDBContext,
            ILoggerFactory loggerFactory
            )
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

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

            app.UseCors(x => x
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader()
                        .AllowCredentials());

            app.UseAuthentication();

            app.UseStaticFiles();

            surveyDBContext.CreateSeedData();

            questionTypeDBContext.CreateSeedData();

            userDBContext.CreateSeedData();

            app.UseHttpsRedirection();

            app.UseMvc();
        }