예제 #1
0
        protected void UpdateRace()
        {
            // Note: This is available to allow minor edits to races previously scored

            var ctx    = new SailTallyDataContext();
            var raceId = SelectedRace;

            // ReSharper disable once LoopCanBePartlyConvertedToQuery
            foreach (var fsr in _fleetSeriesRace)
            {
                if (!fsr.Added)
                {
                    continue;
                }

                var raceSeries = new SS_RaceSery
                {
                    SeasonID      = SelectedSeason,
                    RaceID        = raceId,
                    FleetSeriesID = fsr.FleetSeriesId,
                    RaceNumber    = fsr.RaceNo
                };
                ctx.SS_RaceSeries.InsertOnSubmit(raceSeries);
            }

            ctx.SubmitChanges();
        }
예제 #2
0
        protected void SaveRace()
        {
            // Note: This presumes a new Race ID is created (so if editing, the previous race should have been removed first)

            var ctx  = new SailTallyDataContext();
            var race = new SS_Race()
            {
                SeasonID = SelectedSeason, FirstWarningDate = SelectedWarning
            };

            ctx.SS_Races.InsertOnSubmit(race);
            ctx.SubmitChanges();

            // ReSharper disable once LoopCanBePartlyConvertedToQuery
            foreach (var fsr in _fleetSeriesRace)
            {
                var raceSeries = new SS_RaceSery
                {
                    SeasonID      = SelectedSeason,
                    RaceID        = race.RaceID,
                    FleetSeriesID = fsr.FleetSeriesId,
                    RaceNumber    = fsr.RaceNo
                };
                // use the newly created primary key
                ctx.SS_RaceSeries.InsertOnSubmit(raceSeries);
            }
            ctx.SubmitChanges();
        }