示例#1
0
        public void SetConnections(List <Country> allCountries)
        {
            // If we haven't set the list of connected countries based on the IDs
            // from the database, we do that here

            if (Connections == null || CountryConnections.Count != Connections.Count)
            {
                List <ulong> ids = CountryConnections.Select(a => a.CountryOneID).Concat(
                    CountryConnections.Select(a => a.CountryTwoID).ToList())
                                   .Where(a => a != this.Id).ToList();

                Connections = allCountries.Where(a => ids.Contains(a.Id)).ToList();
            }
        }
示例#2
0
        public void AddConnections(List <Country> countries)
        {
            // Allows us to add a list of countries, and also have them
            // be added to the Entity Model relevant data structures

            Connections = countries;
            foreach (Country country in countries)
            {
                CountryConnection conn = new CountryConnection();
                conn.CountryOneID = this.Id;
                conn.CountryTwoID = country.Id;

                CountryConnections.Add(conn);
            }
        }