Example #1
0
        public async Task <IActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(RecordNotFound());
            }
            var getOperation = await _bo.ReadAsync((Guid)id);

            if (!getOperation.Success)
            {
                return(OperationErrorBackToIndex(getOperation.Exception));
            }
            if (getOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getQOperation = await _qbo.ReadAsync(getOperation.Result.QuizId);

            if (!getQOperation.Success)
            {
                return(OperationErrorBackToIndex(getQOperation.Exception));
            }
            if (getQOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var vm = QuizQuestionViewModel.Parse(getOperation.Result);

            ViewData["Title"] = "Quiz Question";

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "New", Controller = "QuizQuestions", Icon = "fa-search", Text = "Detail"
            });
            ViewData["Quiz"] = QuizViewModel.Parse(getQOperation.Result);

            ViewData["BreadCrumbs"] = crumbs;
            return(View(vm));
        }
Example #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);
        }