Skip to content

Commit

Permalink
Fix Bug when season to team relation is deleted.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanDeveloper committed Jun 26, 2017
1 parent 2c9edd5 commit 6a977f0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion LigaManagerServer/Services/AdminClientService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using LigaManagerServer.Contracts;
using LigaManagerServer.Interfaces;
using LigaManagerServer.Models;
using NHibernate.Util;

namespace LigaManagerServer.Services
{
Expand Down Expand Up @@ -183,7 +184,16 @@ public bool DeleteSeasonToTeamRelation(SeasonToTeamRelation seasonToTeamRelation
{
lock (StaticLock)
{
return _seasonToTeamRelationService.Delete(seasonToTeamRelation);
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;
}
}

Expand Down

0 comments on commit 6a977f0

Please sign in to comment.