public bool AddSeasonToTeamRelation(SeasonToTeamRelation seasonToTeamRelation) { lock (StaticLock) { return(_seasonToTeamRelationService.Add(seasonToTeamRelation)); } }
public bool DeleteSeasonToTeamRelation(SeasonToTeamRelation seasonToTeamRelation) { lock (StaticLock) { var isDeleted = _seasonToTeamRelationService.Delete(seasonToTeamRelation); if (!isDeleted) { return(false); } // delete matches var matches = _matchPersistenceService.GetAll(); matches.Where(x => x.HomeTeam.Equals(seasonToTeamRelation.Team) || x.AwayTeam.Equals(seasonToTeamRelation.Team)).ForEach(x => _matchPersistenceService.Delete(x)); // delete bets var bets = _betPersistenceService.GetAll(); bets.Where(x => x.Match.HomeTeam.Equals(seasonToTeamRelation.Team) || x.Match.AwayTeam.Equals(seasonToTeamRelation.Team)).ForEach(x => _betPersistenceService.Delete(x)); return(true); } }