private void SeedData(MidTermDbContext context) { var surveyUser = new List <SurveyUser> { new SurveyUser { Id = 1, FirstName = "Vik", LastName = "Kalachevski", DoB = DateTime.Today.AddYears(-1), Country = "Macedonia" }, new SurveyUser { Id = 2, FirstName = "Vikk", LastName = "Kalachevskii", DoB = DateTime.Today.AddYears(-1), Country = "Macedoniaa" } }; var answer = new List <Answers> { new Answers { Id = 1, UserId = 1, OptionId = 1 }, new Answers { Id = 1, UserId = 1, OptionId = 1 }, }; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, MidTermDbContext db) { db.Database.EnsureCreated(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
protected SqlLiteContext(bool withData = false) { _connection = new SqliteConnection(InMemoryConnectionString); DbContext = new MidTermDbContext(CreateOptions()); _connection.Open(); DbContext.Database.EnsureCreated(); if (withData) { SeedData(DbContext); } }
private void SeedData(MidTermDbContext context) { var question = new List <Question> { new Question { Id = 1, Text = "Question 1?", Description = "Description 1" }, new Question { Id = 2, Text = "Question 2?", Description = "Description 2" } }; var option = new List <Option> { new Option { Id = 1, Text = "Option 1", Order = 1, QuestionId = 1 }, new Option { Id = 2, Text = "Option 2", Order = 2, QuestionId = 1 }, new Option { Id = 3, Text = "Option 3", Order = 3, QuestionId = 2 }, new Option { Id = 4, Text = "Option 4", Order = 4, QuestionId = 2 } }; context.AddRange(question); context.AddRange(option); context.SaveChanges(); }
protected SqlLiteContext(bool withData = false) { _connection = new SqliteConnection(InMemoryConnectionString); DbContext = new MidTermDbContext(CreateOptions()); _connection.Open(); DbContext.Database.EnsureCreated(); //When we create an instance, we would like to already have data in it. SeedData(DbContext); if (withData) { SeedData(DbContext); } }
private void SeedData(MidTermDbContext dbContext) { var options = new List <Option> { new Option { Id = 1, Text = "Option1" }, new Option { Id = 2, Text = "Option2" }, new Option { Id = 3, Text = "Option3" } }; var questions = new List <Question> { new Question { Id = 1, Description = "Question1" }, new Question { Id = 2, Description = "Question2" }, new Question { Id = 3, Description = "Question3" }, new Question { Id = 4, Description = "Question4" }, }; dbContext.AddRange(options); dbContext.AddRange(questions); dbContext.SaveChanges(); }
private void SeedData(MidTermDbContext context) { var questions = new List <Question> { new Question { Id = 1, Text = "Question 1", Description = "Description 1", Options = new List <Option>() }, new Question { Id = 2, Text = "Question 2", Description = "Description 2", Options = new List <Option>() }, new Question { Id = 3, Text = "Question 3", Description = "Description 3", Options = new List <Option>() } }; var options = new List <Option> { new Option { Id = 1, Text = "Option text 1", QuestionId = 1 }, new Option { Id = 2, Text = "Option text 2", QuestionId = 1 }, new Option { Id = 3, Text = "Option text 3", QuestionId = 1 }, new Option { Id = 4, Text = "Option text 4", QuestionId = 2 }, new Option { Id = 5, Text = "Option text 5", QuestionId = 2 }, new Option { Id = 6, Text = "Option text 6", QuestionId = 2 } }; context.Questions.AddRange(questions); context.Options.AddRange(options); context.SaveChanges(); }
private void SeedData(MidTermDbContext dbContext) { var answers = new List <Answers> { new Answers { Id = 1, UserId = 1, OptionId = 1 }, new Answers { Id = 1, UserId = 2, OptionId = 2 }, new Answers { Id = 1, UserId = 3, OptionId = 1 }, }; var option = new List <Option> { new Option { Id = 1, Text = "SomeOption1", Order = 1, QuestionId = 1 }, new Option { Id = 2, Text = "SomeOption2", Order = 2, QuestionId = 1 }, new Option { Id = 3, Text = "SomeOption3", Order = 2, QuestionId = 2 }, new Option { Id = 4, Text = "SomeOption4", Order = 1, QuestionId = 2 }, }; var question = new List <Question> { new Question { Id = 1, Text = "A Question 1", Description = "Something interesting", }, new Question { Id = 2, Text = "A Question 2", Description = "Something interesting", }, new Question { Id = 3, Text = "A Question 3", Description = "Something interesting", }, new Question { Id = 4, Text = "A Question 4", Description = "Something interesting", }, new Question { Id = 5, Text = "A Question 5", Description = "Something interesting", }, }; var user = new List <SurveyUser> { new SurveyUser { Id = 1, FirstName = "Marko", LastName = "Stojmenovski", DoB = DateTime.Today.AddYears(-20), Gender = (Data.Enums.Gender) 1, Country = "North Macedonia", }, new SurveyUser { Id = 2, FirstName = "John", LastName = "Smith", DoB = DateTime.Today.AddYears(-23), Gender = (Data.Enums.Gender) 1, Country = "United States", }, new SurveyUser { Id = 3, FirstName = "Jane", LastName = "Doe", DoB = DateTime.Today.AddYears(-26), Gender = (Data.Enums.Gender) 2, Country = "United Kingdom", }, }; dbContext.AddRange(answers); dbContext.AddRange(option); dbContext.AddRange(question); dbContext.AddRange(user); dbContext.SaveChanges(); }
public AnswerService(MidTermDbContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public SurveyUserService(MidTermDbContext context, IMapper mapper) { _context = context; _mapper = mapper; }
private void SeedData(MidTermDbContext dbContext) { var surveyUser = new List <SurveyUser>() { new SurveyUser { Id = 1, FirstName = "First Name", LastName = "Last name", DoB = DateTime.Today.AddYears(-21), Gender = Data.Enums.Gender.Male, Country = "Makedonija" }, new SurveyUser { Id = 2, FirstName = "First Name2", LastName = "Last name2", DoB = DateTime.Today.AddYears(-20), Gender = Data.Enums.Gender.Male, Country = "Makedonija" }, new SurveyUser { Id = 3, FirstName = "First Name3", LastName = "Last name3", DoB = DateTime.Today.AddYears(-19), Gender = Data.Enums.Gender.Female, Country = "Makedonija" }, new SurveyUser { Id = 4, FirstName = "First Name4", LastName = "Last name4", DoB = DateTime.Today.AddYears(-18), Gender = Data.Enums.Gender.Female, Country = "Makedonija" } }; var answers = new List <Answers>() { new Answers { Id = 1, UserId = 1, OptionId = 1 }, new Answers { Id = 2, UserId = 2, OptionId = 2 }, new Answers { Id = 3, UserId = 3, OptionId = 3 }, new Answers { Id = 4, UserId = 4, OptionId = 4 } }; dbContext.AddRange(surveyUser); dbContext.AddRange(answers); dbContext.SaveChanges(); }
public OptionService(MidTermDbContext context, IMapper mapper) { _context = context; _mapper = mapper; }
private void SeedData(MidTermDbContext context) { var options = new List <Option> { new Option { Id = 1, Text = "Option1" }, new Option { Id = 2, Text = "Option2" }, new Option { Id = 3, Text = "Option3" } }; var questions = new List <Question> { new Question { Id = 1, Description = "Question1" }, new Question { Id = 2, Description = "Question2" }, new Question { Id = 3, Description = "Question3" }, new Question { Id = 4, Description = "Question4" }, }; /* var playedMatches = new List<PlayerMatch> * { * new PlayerMatch * { * Id = 1, * MatchId = 1, * PlayerId = 1, * Score = 2 * }, * new PlayerMatch * { * Id = 2, * MatchId = 1, * PlayerId = 2, * Score = 1 * }, * new PlayerMatch * { * Id = 3, * MatchId = 2, * PlayerId = 3, * Score = 1 * }, * new PlayerMatch * { * Id = 4, * MatchId = 2, * PlayerId = 4, * Score = 0 * }, * new PlayerMatch * { * Id = 5, * MatchId = 3, * PlayerId = 1, * Score = 3 * }, * new PlayerMatch * { * Id = 6, * MatchId = 3, * PlayerId = 3, * Score = 1 * } * }; */ context.AddRange(options); // context.AddRange(playedMatches); context.AddRange(questions); context.SaveChanges(); }