Exemplo n.º 1
0
        private void bwAddQuestions_DoWork(object sender, DoWorkEventArgs e)
        {
            for (int i = 0; i < game.NumCategories; i++)
            {
                Question newQuestion = new Question();
                newQuestion.CategoryId = (int)game.Categories[i].Id;
                newQuestion.ResetQuestionToDefaults(); //default data
                newQuestion.Weight = (game.NumQuestionsPerCategory) * 100;
                newQuestion.Id     = DB_Insert.InsertQuestion(newQuestion);

                if (newQuestion.Id != null && newQuestion.Id > 0)  //if the insert into db worked
                {
                    game.Categories[i].Questions.Add(newQuestion); //add it to the current game object too
                }
            }
        }
Exemplo n.º 2
0
        private void bwAddCategory_DoWork(object sender, DoWorkEventArgs e)
        {
            Category newCategory = new Category();

            newCategory.GameId = (int)game.Id;
            newCategory.Index  = game.Categories.Count;
            newCategory.ResetCategoryToDefaults(); //other default data
            newCategory.Id        = DB_Insert.InsertCategory(newCategory);
            newCategory.Questions = new List <Question>(new Question[game.NumQuestionsPerCategory]);
            for (int i = 0; i < game.NumQuestionsPerCategory; i++)
            {
                newCategory.Questions[i] = new Question();

                newCategory.Questions[i].CategoryId = (int)newCategory.Id;
                newCategory.Questions[i].ResetQuestionToDefaults(); //other default data
                newCategory.Questions[i].Weight = (i + 1) * 100;
                newCategory.Questions[i].Id     = DB_Insert.InsertQuestion(newCategory.Questions[i]);
            }
            game.Categories.Add(newCategory);
        }