public void CreateMatch(Competition competition, List <Party> players, int laneNumber) { var lane = _lanes.FirstOrDefault(l => l.LaneNo == laneNumber); var matchNo = _matches.Where(m => m.Competition == competition).Count() + 1; var match = BowlingFactory.CreateMatch(competition, players, lane, matchNo); _matches.Add(match); _competitions.FirstOrDefault(c => c.Id == competition.Id).Matches.Add(match); }
public void CreateMatch(Competition competition, List <Party> players, int laneNumber) { var lane = _context.Lanes.FirstOrDefault(l => l.LaneNo == laneNumber); var matchNo = competition.Matches.Count + 1; var match = BowlingFactory.CreateMatch(competition, players, lane, matchNo); _context.Competitions.FirstOrDefault(c => c.Id == competition.Id).Matches.Add(match); _context.SaveChanges(); }