Esempio n. 1
0
        public void TestCreateQuizAsync()
        {
            BoraNowSeeder.Seed();
            var _quiz     = new Quiz("Questionário BoraNow");
            var _bo       = new QuizBusinessObject();
            var resCreate = _bo.CreateAsync(_quiz).Result;
            var resGet    = _bo.ReadAsync(_quiz.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("Title")] QuizViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var quiz            = vm.ToQuiz();
                var createOperation = await _bo.CreateAsync(quiz);

                if (!createOperation.Success)
                {
                    return(OperationErrorBackToIndex(createOperation.Exception));
                }
                return(OperationSuccess("The record was successfuly created"));
            }
            return(View(vm));
        }