Пример #1
0
        public async Task <IActionResult> Create([Bind("Question", "QuizId")] QuizQuestionViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var quizAnswer      = vm.ToQuizQuestion();
                var createOperation = await _bo.CreateAsync(quizAnswer);

                if (!createOperation.Success)
                {
                    return(OperationErrorBackToIndex(createOperation.Exception));
                }
                return(OperationSuccess("The record was successfuly created"));
            }
            return(View(vm));
        }
Пример #2
0
        public void TestCreateQuizQuestionAsync()
        {
            BoraNowSeeder.Seed();
            var qqbo = new QuizQuestionBusinessObject();
            var qbo  = new QuizBusinessObject();

            var quiz = new Quiz("This quiz rocks");

            qbo.Create(quiz);

            var quizQuestion = new QuizQuestion("do u like wine?", quiz.Id);

            var resCreate = qqbo.CreateAsync(quizQuestion).Result;
            var resGet    = qqbo.ReadAsync(quizQuestion.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }