// GET: Quizs/Create
        public ActionResult Create()
        {
            QuizCategoriesViewModel model = new QuizCategoriesViewModel();

            model.Quiz           = new Models.Quiz();
            model.QuizCategories = db.QuizCategories.ToList();
            return(View(model));
        }
        public ActionResult Index()
        {
            var allCategories = apiClient.GetCategories().Result;
            var model         = new QuizCategoriesViewModel
            {
                Categories = allCategories.Select(
                    c => new QuizCategoryViewModel()
                {
                    Id = c.Id, Name = c.Name, Description = c.Description
                }).ToList()
            };

            return(View(model));
        }
 // GET: Quizs/Edit/5
 public ActionResult Edit(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     Models.Quiz quiz = db.Quizs.Find(id);
     if (quiz == null)
     {
         return(HttpNotFound());
     }
     else
     {
         QuizCategoriesViewModel model = new QuizCategoriesViewModel();
         model.Quiz           = quiz;
         model.QuizCategories = db.QuizCategories.ToList();
         return(View(model));
     }
 }
Beispiel #4
0
        public ActionResult Index()
        {
            try
            {
                var allCategories = apiClient.GetCategories().Result;
                var model         = new QuizCategoriesViewModel
                {
                    Categories = allCategories.Select(
                        c => new QuizCategoryViewModel()
                    {
                        Id = c.Id, Name = c.Name, Description = c.Description
                    }).ToList()
                };
                model.ShowRandomCategory = true;

                return(View(model));
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
                Response.End();
            }
            return(null);
        }