コード例 #1
0
        public async Task <IActionResult> Selected(int?id)
        {
            PopulateComponentTypeList();

            if (id == null)
            {
                //show all components
                return(View(await _context.Components.ToListAsync()));
            }

            ViewData["ComponentTypeID"] = id;

            var components = await _context.Components
                             .Where(c => c.ComponentType.ComponentTypeID == id)
                             .Include(c => c.ComponentType)
                             .ToListAsync();

            var ct = _context.ComponentTypes
                     .Where(c => c.ComponentTypeID == id)
                     .Single();

            ViewData["CTName"] = ct.ComponentTypeName;

            var viewModel = new ComponentIndexData();

            viewModel.Components = components;
            return(View(viewModel));
        }
コード例 #2
0
        // GET: Components
        public async Task <IActionResult> Index()
        {
            ViewData["CTName"] = "all";
            PopulateComponentTypeList();
            var viewModel = new ComponentIndexData();

            viewModel.Components = await _context.Components
                                   .Include(c => c.ComponentType)
                                   .ToListAsync();

            return(View("Selected", viewModel));
        }