Exemple #1
0
        public ActionResult Edit(CreateEditTestModel testmodel)
        {
            int id = (int)Session["id"];

            testmodel.EditTest(id);
            return(RedirectToAction("ManageSurveys", "Admin"));
        }
Exemple #2
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));
        }
Exemple #3
0
 public ActionResult CreateTest(CreateEditTestModel testModel)
 {
     if ((String.IsNullOrWhiteSpace(testModel.Title) || testModel.Title.Length < 5) || testModel.CreatingQuestionmodels.Count(x => x.Soru != null && x.Choices.Count(p => p.Length > 0) > 1) < 1)
     {
         return(RedirectToAction("CreateTest", "Admin"));
     }
     else
     {
         testModel.CreateTest();
         return(RedirectToAction("ManageSurveys", "Admin"));
     }
 }
Exemple #4
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));
        }