示例#1
0
        public IActionResult OnGet()
        {
            ViewData["PublisherID"] = new SelectList(_context.Set <Publisher>(), "ID", "PublisherName");
            var picture = new Picture();

            picture.PictureCategories = new List <PictureCategory>();
            PopulateAssignedCategoryData(_context, picture);
            return(Page());
        }
示例#2
0
        public async Task<IActionResult> OnGetAsync(int? id)
        {
            if (id == null)
            {
                return NotFound();
            }

            Picture = await _context.Picture
                .Include(b => b.Publisher)
               .Include(b => b.PictureCategories).ThenInclude(b => b.Category)
                  .AsNoTracking()
                .FirstOrDefaultAsync(m => m.ID == id);

            if (Picture == null)
            {
                return NotFound();
            }
            PopulateAssignedCategoryData(_context, Picture);
            ViewData["PublisherID"] = new SelectList(_context.Set<Publisher>(), "ID", "PublisherName");
            return Page();
        }