Exemplo n.º 1
0
        public async Task <ActionResult> CreateSomeTest()
        {
            TestDto test = new TestDto()
            {
                Name      = "another test",
                Questions = new List <QuestionDto>()
                {
                    new QuestionDto()
                    {
                        Content        = "Which city is capital of United Kingdom",
                        RightAnswers   = 1,
                        QuestionTypeId = QuestionTypeEnum.Closed,
                        Options        = new List <QuestionAnswerOptionDto>()
                        {
                            new QuestionAnswerOptionDto()
                            {
                                Content   = "London",
                                IsCorrect = true
                            },
                            new QuestionAnswerOptionDto()
                            {
                                Content   = "Cardiff",
                                IsCorrect = false
                            },
                            new QuestionAnswerOptionDto()
                            {
                                Content   = "Manchester",
                                IsCorrect = false
                            }
                        }
                    },
                    new QuestionDto()
                    {
                        Content        = "Why you read books",
                        Options        = null,
                        QuestionTypeId = QuestionTypeEnum.Open
                    },
                    new QuestionDto()
                    {
                        Content        = "which disciplines you have this semester",
                        QuestionTypeId = QuestionTypeEnum.Closed,
                        Options        = new List <QuestionAnswerOptionDto>()
                        {
                            new QuestionAnswerOptionDto()
                            {
                                Content   = "Entity framework",
                                IsCorrect = true
                            },
                            new QuestionAnswerOptionDto()
                            {
                                Content   = "Business modeling",
                                IsCorrect = true
                            },
                            new QuestionAnswerOptionDto()
                            {
                                Content   = "Some kind of math",
                                IsCorrect = false
                            }
                        }
                    }
                }
            };

            try
            {
                await service.CreateTestAsync(test);
            }
            catch (Exception ex)
            {
                ViewBag.Exception = ex.Message;
            }

            return(View());
        }