public async Task <IActionResult> Create()
        {
            var qqListOperation = await _qqbo.ListAsync();

            if (!qqListOperation.Success)
            {
                return(OperationErrorBackToIndex(qqListOperation.Exception));
            }
            var qqList = new List <QuizQuestionViewModel>();

            foreach (var qq in qqListOperation.Result)
            {
                if (!qq.IsDeleted)
                {
                    var qqvm = QuizQuestionViewModel.Parse(qq);
                    qqList.Add(qqvm);
                }
                ViewBag.QuizQuestions = qqList.Select(qq => new SelectListItem()
                {
                    Text = qq.Question, Value = qq.Id.ToString()
                });
            }

            ViewData["Title"] = "New Answer";
            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "New", Controller = "QuizAnswers", Icon = "fa-plus", Text = "New"
            });
            ViewData["BreadCrumbs"] = crumbs;
            return(View());
        }
Esempio n. 2
0
        public async Task <IActionResult> QuizStart(/*IEnumerable<QuizAnswerViewModel> vm*/)
        {
            var listOperation = await _bo.ListAsync();

            var qqListOperation = await _qqbo.ListAsync();

            var list = new List <QuizAnswerViewModel>();

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

            var qqList = new List <QuizQuestionViewModel>();

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

            ViewBag.QuizQuestions = qqList;
            return(View(list));
        }
        public ActionResult <List <QuizQuestionViewModel> > List()
        {
            var res = _bo.List();

            if (!res.Success)
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
            var list = new List <QuizQuestionViewModel>();

            foreach (var item in res.Result)
            {
                list.Add(QuizQuestionViewModel.Parse(item));
            }
            return(list);
        }
        public async Task <IActionResult> Index()
        {
            var listOperation = await _bo.ListAsync();

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

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

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

            var list = new List <QuizAnswerViewModel>();

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

            var qqList = new List <QuizQuestionViewModel>();

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

            ViewData["Title"]       = "Quiz Answer";
            ViewData["BreadCrumbs"] = GetCrumbs();
            ViewData["DeleteHref"]  = GetDeleteRef();
            ViewBag.QuizQuestions   = qqList;
            return(View(list));
        }
        public ActionResult <QuizQuestionViewModel> Get(Guid id)
        {
            var res = _bo.Read(id);

            if (res.Success)
            {
                if (res.Result == null)
                {
                    return(NotFound());
                }
                var cvm = QuizQuestionViewModel.Parse(res.Result);
                return(cvm);
            }
            else
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
        }
        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 getQQOperation = await _qqbo.ReadAsync(getOperation.Result.QuizQuestionId);

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

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

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

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "New", Controller = "QuizAnswers", Icon = "fa-search", Text = "Detail"
            });
            ViewData["QuizQuestion"] = QuizQuestionViewModel.Parse(getQQOperation.Result);

            ViewData["BreadCrumbs"] = crumbs;
            return(View(vm));
        }
Esempio n. 7
0
        public async Task <IActionResult> Edit(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 vm = QuizQuestionViewModel.Parse(getOperation.Result);
            var listIpOperation = await _qbo.ListAsync();

            if (!listIpOperation.Success)
            {
                return(OperationErrorBackToIndex(listIpOperation.Exception));
            }
            var qList = new List <SelectListItem>();

            foreach (var item in listIpOperation.Result)
            {
                if (!item.IsDeleted)
                {
                    var listItem = new SelectListItem()
                    {
                        Value = item.Id.ToString(), Text = item.Title
                    };
                    if (item.Id == vm.QuizId)
                    {
                        listItem.Selected = true;
                    }
                    qList.Add(listItem);
                }
            }

            ViewBag.Quizzes   = qList;
            ViewData["Title"] = "Edit Quiz Question";
            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "Edit", Controller = "QuizQuestion", Icon = "fa-edit", Text = "Edit"
            });
            ViewData["BreadCrumbs"] = crumbs;
            return(View(vm));


            //var vm = QuizQuestionViewModel.Parse(getOperation.Result);
            //ViewData["Title"] = "Edit Question";
            //var crumbs = GetCrumbs();
            //crumbs.Add(new BreadCrumb() { Action = "Edit", Controller = "QuizQuestions", Icon = "fa-edit", Text = "Edit" });
            //ViewData["BreadCrumbs"] = crumbs;
            //return View(vm);
        }