Пример #1
0
        public ActionResult Edit(int id)
        {
            Session["id"] = id;
            CreateEditTestModel createEditTestModel = new CreateEditTestModel();

            createEditTestModel.CreatingQuestionmodels = new List <CreatingTestQuestionmodel>();
            createEditTestModel.EditQuestionModels     = new List <EditQuestionModel>();
            SurveyDbContext surveyEntities = new SurveyDbContext();

            createEditTestModel.Title = surveyEntities.Tests.Single(x => x.TestId == id).Title;
            foreach (var item in surveyEntities.Questions.Where(x => x.TestId == id).Include(x => x.Choices))
            {
                List <Choice> vs = new List <Choice>();
                foreach (var item1 in item.Choices)
                {
                    Choice choice = item1;
                    vs.Add(choice);
                }
                EditQuestionModel editQuestionModel = new EditQuestionModel {
                    Questionİd = item.QuestionId, Choices = vs, Soru = item.Soru
                };
                createEditTestModel.EditQuestionModels.Add(editQuestionModel);
            }
            for (int i = 0; i < (10 - createEditTestModel.EditQuestionModels.Count); i++)
            {
                CreatingTestQuestionmodel model = new CreatingTestQuestionmodel();
                model.Choices = new List <string>();
                for (int j = 0; j < 5; j++)
                {
                    model.Choices.Add("");
                }
                createEditTestModel.CreatingQuestionmodels.Add(model);
            }
            return(View("CreateTest", createEditTestModel));
        }
Пример #2
0
        // GET: Admin
        public ActionResult CreateTest()
        {
            CreateEditTestModel testModel = new CreateEditTestModel();

            testModel.CreatingQuestionmodels = new List <CreatingTestQuestionmodel>();
            testModel.EditQuestionModels     = new List <EditQuestionModel>();
            for (int i = 0; i < 10; i++)
            {
                CreatingTestQuestionmodel model = new CreatingTestQuestionmodel();
                model.Choices = new List <string>();
                for (int j = 0; j < 5; j++)
                {
                    model.Choices.Add("");
                }
                testModel.CreatingQuestionmodels.Add(model);
            }
            return(View(testModel));
        }