示例#1
0
        public ActionResult List(string categoryKey)
        {
            var category = _categoryService.Load(categoryKey);
            if(category == null)
                throw new InvalidOperationException("Category with key " + categoryKey + " not found.");

            Lesson[] lessons = _lessonService.Find(categoryKey);

            var lessonListViewModel = new LessonListViewModel(lessons, category.Name);

            return View("List", lessonListViewModel);
        }
示例#2
0
        public IndexViewModel(Category[] categories, Lesson[] lessons)
        {
            CategoryList = new CategoryListViewModel(categories);
            LessonLists = new LessonListViewModel[categories.Length];

            for (int i = 0; i < categories.Length; i++)
            {
                LessonLists[i] = new LessonListViewModel
                (
                    lessons.Where(les => les.CategoryId == categories[i].Id).ToArray(),
                    categories[i].Name
                );
            }
        }