Exemplo n.º 1
0
        public async Task <IActionResult> Index()
        {
            var listOperation = await _bo.ListAsync();

            if (!listOperation.Success)
            {
                return(OperationErrorBackToIndex(listOperation.Exception));
            }
            var lst = new List <ResultViewModel>();

            foreach (var item in listOperation.Result)
            {
                if (!item.IsDeleted)
                {
                    lst.Add(ResultViewModel.Parse(item));
                }
            }
            var qlistOperation = await _qbo.ListAsync();

            if (!qlistOperation.Success)
            {
                return(OperationErrorBackToIndex(qlistOperation.Exception));
            }
            var quizlst = new List <QuizViewModel>();

            foreach (var item in qlistOperation.Result)
            {
                if (!item.IsDeleted)
                {
                    quizlst.Add(QuizViewModel.Parse(item));
                }
            }
            var vlistOperation = await _vbo.ListAsync();

            if (!vlistOperation.Success)
            {
                return(OperationErrorBackToIndex(vlistOperation.Exception));
            }
            var visitorlst = new List <VisitorViewModel>();

            foreach (var item in vlistOperation.Result)
            {
                if (!item.IsDeleted)
                {
                    visitorlst.Add(VisitorViewModel.Parse(item));
                }
            }

            ViewData["Title"]       = "Results Quiz";
            ViewData["Breadcrumbs"] = GetCrumbs();
            ViewData["DeleteHref"]  = GetDeleteRef();
            ViewData["Quizzes"]     = quizlst;
            ViewData["Visitors"]    = visitorlst;
            return(View(lst));
        }
Exemplo n.º 2
0
        public void TestListQuizAsync()
        {
            BoraNowSeeder.Seed();
            var bo      = new QuizBusinessObject();
            var resList = bo.ListAsync().Result;

            Assert.IsTrue(resList.Success && resList.Result.Count == 1);
        }
Exemplo n.º 3
0
        public void TesDeletetQuizAsync()
        {
            BoraNowSeeder.Seed();
            var bo        = new QuizBusinessObject();
            var resList   = bo.List();
            var resDelete = bo.DeleteAsync(resList.Result.First().Id).Result;

            resList = bo.ListAsync().Result;

            Assert.IsTrue(resDelete.Success && resList.Success && resList.Result.First().IsDeleted);
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Index()
        {
            var listOperation = await _bo.ListAsync();

            if (!listOperation.Success)
            {
                return(OperationErrorBackToIndex(listOperation.Exception));
            }
            var qListOperation = await _qbo.ListAsync();

            if (!qListOperation.Success)
            {
                return(OperationErrorBackToIndex(qListOperation.Exception));
            }

            var list = new List <QuizQuestionViewModel>();

            foreach (var item in listOperation.Result)
            {
                if (!item.IsDeleted)
                {
                    list.Add(QuizQuestionViewModel.Parse(item));
                }
            }

            var qList = new List <QuizViewModel>();

            foreach (var item in qListOperation.Result)
            {
                if (!item.IsDeleted)
                {
                    qList.Add(QuizViewModel.Parse(item));
                }
            }

            ViewData["Title"]       = "Quiz Question";
            ViewData["BreadCrumbs"] = GetCrumbs();
            ViewData["DeleteHref"]  = GetDeleteRef();
            ViewBag.Quizzes         = qList;
            return(View(list));
        }
Exemplo n.º 5
0
        public void TestUpdateQuizAsync()
        {
            BoraNowSeeder.Seed();
            var qbo     = new QuizBusinessObject();
            var resList = qbo.List();

            var quiz    = resList.Result.FirstOrDefault();
            var newQuiz = new Quiz("BoraNow Quiz");

            quiz.Title = newQuiz.Title;

            var resUpdate = qbo.UpdateAsync(quiz).Result;

            resList = qbo.ListAsync().Result;
            Assert.IsTrue(resUpdate.Success && resList.Success && resList.Result.First().Title == quiz.Title);
        }