Ejemplo n.º 1
0
        public List <TournamentQueries.GuestPackage> GetGuestPackages(string year)
        {
            var tournament    = Tournaments.Single(x => x.Year == year);
            var guestPackages = GuestPackages.Where(x => x.TournamentId == tournament.Id).ToList();

            var defaultPackages = new [] {
                new TournamentQueries.GuestPackage
                {
                    TournamentId = tournament.Id,
                    Code         = "Option1",
                    Name         = "Meet & Greet",
                    Enabled      = true
                },
                new TournamentQueries.GuestPackage
                {
                    TournamentId = tournament.Id,
                    Code         = "Option2",
                    Name         = "Transportation",
                    Enabled      = true
                },
                new TournamentQueries.GuestPackage
                {
                    TournamentId = tournament.Id,
                    Code         = "Option3",
                    Name         = "Provincial Night",
                    Enabled      = true
                },
                new TournamentQueries.GuestPackage
                {
                    TournamentId = tournament.Id,
                    Code         = "Option4",
                    Name         = "Victory Banquet",
                    Enabled      = true
                }
            }.ToList();

            var mergedPackages = (
                from d in defaultPackages
                join g in guestPackages
                on d.Code equals g.Code into joined
                from j in joined.DefaultIfEmpty()
                select j ?? d).ToList();

            return(mergedPackages);
        }
Ejemplo n.º 2
0
        public void Handle(GuestPackageSaved e)
        {
            //TODO: Chad: Overwrite existing
            var package = GuestPackages.SingleOrDefault(x => x.TournamentId == e.Id && x.Code == e.Code);

            if (package == null)
            {
                GuestPackages.Add(new GuestPackage
                {
                    TournamentId = e.Id,
                    Code         = e.Code,
                    Name         = e.Name,
                    Cost         = e.Cost,
                    Enabled      = e.Enabled
                });
            }
            else
            {
                package.Name    = e.Name;
                package.Cost    = e.Cost;
                package.Enabled = e.Enabled;
            }
        }