multistore
Razmig Sarkissian 1 year ago
parent d3c658c615
commit 61d0c94cee
  1. 25
      PadelClub/Data/Tournament.swift

@ -1175,18 +1175,35 @@ class Tournament : ModelObject, Storable {
} }
func deleteStructure() { func deleteStructure() {
try? DataStore.shared.rounds.delete(contentOfs: rounds()) do {
try DataStore.shared.rounds.delete(contentOfs: rounds())
} catch {
Logger.error(error)
}
unsortedTeams().forEach({ $0.bracketPosition = nil }) unsortedTeams().forEach({ $0.bracketPosition = nil })
try? DataStore.shared.teamRegistrations.addOrUpdate(contentOfs: unsortedTeams()) do {
try DataStore.shared.teamRegistrations.addOrUpdate(contentOfs: unsortedTeams())
} catch {
Logger.error(error)
}
} }
func deleteGroupStages() { func deleteGroupStages() {
try? DataStore.shared.groupStages.delete(contentOfs: groupStages()) do {
try DataStore.shared.groupStages.delete(contentOfs: groupStages())
} catch {
Logger.error(error)
}
do {
unsortedTeams().forEach({ unsortedTeams().forEach({
$0.groupStage = nil $0.groupStage = nil
$0.groupStagePosition = nil $0.groupStagePosition = nil
}) })
try? DataStore.shared.teamRegistrations.addOrUpdate(contentOfs: unsortedTeams()) try DataStore.shared.teamRegistrations.addOrUpdate(contentOfs: unsortedTeams())
} catch {
Logger.error(error)
}
} }
func refreshGroupStages() { func refreshGroupStages() {

Loading…
Cancel
Save