Skip to content

Commit

Permalink
Fix bug that occur when match will be deleted.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanDeveloper committed Jun 26, 2017
1 parent 6a977f0 commit 5c3308b
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions LigaManagerServer/Services/AdminClientService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ public bool DeleteMatch(Match match)
{
lock (StaticLock)
{
return _matchPersistenceService.Delete(match);
var isDeletd = _matchPersistenceService.Delete(match);
if (!isDeletd) return false;
var bets = _betPersistenceService.GetAll();
bets.Where(x => x.Match.Equals(match)).ForEach(x => _betPersistenceService.Delete(x));
return true;
}
}

Expand Down Expand Up @@ -185,15 +189,12 @@ public bool DeleteSeasonToTeamRelation(SeasonToTeamRelation seasonToTeamRelation
lock (StaticLock)
{
var isDeleted = _seasonToTeamRelationService.Delete(seasonToTeamRelation);
if (isDeleted)
{
var matches = _matchPersistenceService.GetAll();
var bets = _betPersistenceService.GetAll();
matches.Where(x => x.HomeTeam.Equals(seasonToTeamRelation.Team) || x.AwayTeam.Equals(seasonToTeamRelation.Team)).ForEach(x => _matchPersistenceService.Delete(x));
bets.Where(x => x.Match.HomeTeam.Equals(seasonToTeamRelation.Team) || x.Match.AwayTeam.Equals(seasonToTeamRelation.Team)).ForEach(x => _betPersistenceService.Delete(x));
return true;
}
return false;
if (!isDeleted) return false;
var matches = _matchPersistenceService.GetAll();
var bets = _betPersistenceService.GetAll();
matches.Where(x => x.HomeTeam.Equals(seasonToTeamRelation.Team) || x.AwayTeam.Equals(seasonToTeamRelation.Team)).ForEach(x => _matchPersistenceService.Delete(x));
bets.Where(x => x.Match.HomeTeam.Equals(seasonToTeamRelation.Team) || x.Match.AwayTeam.Equals(seasonToTeamRelation.Team)).ForEach(x => _betPersistenceService.Delete(x));
return true;
}
}

Expand Down

0 comments on commit 5c3308b

Please sign in to comment.