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 vm = QuizViewModel.Parse(getOperation.Result);

            ViewData["Title"] = "Quiz";

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "New", Controller = "Quizzes", Icon = "fa-search", Text = "Detail"
            });

            ViewData["BreadCrumbs"] = crumbs;
            return(View(vm));
        }
Example #2
0
        public async Task <IActionResult> Create()
        {
            var qListOperation = await _qbo.ListAsync();

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

            foreach (var q in qListOperation.Result)
            {
                if (!q.IsDeleted)
                {
                    var qvm = QuizViewModel.Parse(q);
                    qList.Add(qvm);
                }
                ViewBag.Quizzes = qList.Select(q => new SelectListItem()
                {
                    Text = q.Title, Value = q.Id.ToString()
                });
            }

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

            crumbs.Add(new BreadCrumb()
            {
                Action = "New", Controller = "QuizQuestions", Icon = "fa-plus", Text = "New"
            });
            ViewData["BreadCrumbs"] = crumbs;
            return(View());
        }
Example #3
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));
        }
Example #4
0
        public async Task <IActionResult> Create()
        {
            var qListOperation = await _qbo.ListAsync();

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

            foreach (var item in qListOperation.Result)
            {
                if (!item.IsDeleted)
                {
                    var qvm = QuizViewModel.Parse(item);
                    quizList.Add(qvm);
                }
                ViewBag.Quizzes = quizList.Select(r => new SelectListItem()
                {
                    Text = r.Title, Value = r.Id.ToString()
                });
            }
            var vListOperation = await _vbo.ListAsync();

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

            foreach (var item in vListOperation.Result)
            {
                if (!item.IsDeleted)
                {
                    var vvm = VisitorViewModel.Parse(item);
                    visitorList.Add(vvm);
                }
                ViewBag.Visitors = visitorList.Select(v => new SelectListItem()
                {
                    Text = v.FirstName, Value = v.Id.ToString()
                });
            }

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

            crumbs.Add(new BreadCrumb()
            {
                Action = "Create", Controller = "Results", Icon = "fa-plus", Text = "New"
            });
            ViewData["BreadCrumbs"] = crumbs;
            return(View());
        }
Example #5
0
        public ActionResult <List <QuizViewModel> > List()
        {
            var res = _bo.List();

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

            foreach (var item in res.Result)
            {
                list.Add(QuizViewModel.Parse(item));
            }
            return(list);
        }
Example #6
0
        public ActionResult <QuizViewModel> Get(Guid id)
        {
            var res = _bo.Read(id);

            if (res.Success)
            {
                if (res.Result == null)
                {
                    return(NotFound());
                }
                var cvm = QuizViewModel.Parse(res.Result);
                return(cvm);
            }
            else
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
        }
Example #7
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));
        }