// GET: Items
        public async Task <IActionResult> Index()
        {
            var items = _context.Items.Include(i => i.Guest).Include(i => i.Package);

            var itemsPackages = new ItemPackagesVM {
                items = items
            };

            ViewData["CategoryId"] = new SelectList(_context.Categories, "CategoryId", "CategoryName", itemsPackages.CategoryId);
            ViewData["GuestId"]    = new SelectList(_context.Guests, "GuestId", "GuestFirstName", itemsPackages.GuestId);
            ViewData["PackageId"]  = new SelectList(_context.Packages, "PackageId", "PackageName", itemsPackages.PackageId);
            return(View(itemsPackages));
        }
Beispiel #2
0
        // GET: Items
        public async Task <IActionResult> Index()
        {
            var items = _context.Items.Include(i => i.Guest).Include(i => i.Package);

            var itemsPackages = new ItemPackagesVM {
                items = items
            };

            var guests =
                _context.Guests
                .Select(n => new
            {
                GuestId       = n.GuestId,
                GuestFullName = string.Format("{0} - {1}", n.GuestFullName, n.GuestEmail)
            })
                .ToList();

            ViewData["CategoryId"] = new SelectList(_context.Categories, "CategoryId", "CategoryName");
            ViewData["GuestId"]    = new SelectList(guests, "GuestId", "GuestFullName");
            ViewData["PackageId"]  = new SelectList(_context.Packages, "PackageId", "PackageName");
            return(View(itemsPackages));
        }