Exemplo n.º 1
0
        public IActionResult OnGet()
        {
            ViewData["MakeID"] = new SelectList(_context.Set <Make>(), "ID", "MakeName");

            var product = new Product();

            product.ProductCategories = new List <ProductCategory>();

            PopulateSelectedCategoriesList(_context, product);

            return(Page());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Product = await _context.Product.Include(p => p.Make).Include(p => p.ProductCategories).ThenInclude(p => p.Category).AsNoTracking().FirstOrDefaultAsync(m => m.ID == id);

            if (Product == null)
            {
                return(NotFound());
            }

            PopulateSelectedCategoriesList(_context, Product);

            ViewData["MakeID"] = new SelectList(_context.Set <Make>(), "ID", "MakeName");
            return(Page());
        }