public Race AddRace(Race newRace) { // Add race RacesData raceData = new RacesData(CurrentDataContext); newRace.Id = raceData.AddRace(newRace); RacePowersData powersData = new RacePowersData(CurrentDataContext); foreach (RacePower power in newRace.RacePowers) { power.RaceId = newRace.Id; power.Id = powersData.AddPower(power); } return(newRace); }
public Race EditRace(Race race) { RacesData raceData = new RacesData(CurrentDataContext); raceData.UpdateRace(race); RacePowersData powersData = new RacePowersData(CurrentDataContext); foreach (RacePower power in race.RacePowers) { if (power.Id == 0) { power.RaceId = race.Id; power.Id = powersData.AddPower(power); } else { powersData.UpdatePower(power); } } return(race); }
public void RemovePower(int id) { RacePowersData powersData = new RacePowersData(CurrentDataContext); powersData.RemovePower(id); }