Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        public void RemovePower(int id)
        {
            RacePowersData powersData = new RacePowersData(CurrentDataContext);

            powersData.RemovePower(id);
        }