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

            var product = new Product();

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

            PopulateAssignedCategoryData(_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(b => b.Seller)
                      .Include(b => b.ProductCategories).ThenInclude(b => b.Category)
                      .AsNoTracking()
                      .FirstOrDefaultAsync(m => m.ID == id);


            if (Product == null)
            {
                return(NotFound());
            }
            PopulateAssignedCategoryData(_context, Product);

            ViewData["SellerID"] = new SelectList(_context.Set <Seller>(), "ID", "SellerName");
            return(Page());
        }