public Player(string firstName, string lastName, Country country) { if (country == null) throw new ArgumentNullException("country"); this.firstName = firstName; this.lastName = lastName; this.country = country; }
// factory method example. this one could have been normal constructor public static Match Create(DateTime date, Country team1Country, Country team2Country) { if (team1Country == null) throw new ArgumentNullException("team1Country"); if (team2Country == null) throw new ArgumentNullException("team2Country"); if (team1Country.Equals(team2Country)) throw new ArgumentException("Teams must not be the same country!"); var match = new Match { date = date }; match.teams.Add(new Team(match, team1Country)); match.teams.Add(new Team(match, team2Country)); return match; }
public Country SetUpCountry(string countryName) { using (var uow = unitOfWorkFactory.BeginUnitOfWork()) { var country = uow.Query<Country>().SingleOrDefault(x => x.Name == countryName); if (country != null) return country; country = new Country(countryName); uow.Add(country); uow.Complete(); return country; } }
public int SetUpMatch(Country country1, Country country2) { PopulateCountryPlayerPool(country1.Name); PopulateCountryPlayerPool(country2.Name); using (var uow = unitOfWorkFactory.BeginUnitOfWork()) { var match = Match.Create(DateTime.Today, country1, country2); PickTeam(match.Team1, uow); PickTeam(match.Team2, uow); uow.Add(match); uow.Complete(); return match.Id; } }
internal Team(Match match, Country country) { this.match = match; this.country = country; }
internal Team(Match match, Country country) { Match = match; Country = country; }
public virtual void ChangeCountry(Country country) { if (country == null) throw new ArgumentNullException("country"); this.country = country; }