コード例 #1
0
ファイル: RaceIntermediateTest.cs プロジェクト: heinek/ITimeU
        public void It_Should_Be_Possible_To_Connect_An_Athlete_To_A_Startnumber()
        {
            Given("we have an athlete and a startnumber registrert", () =>
            {
                athlete.ConnectToRace(race.RaceId);
                timer = CreateNewTimerModelWithCheckpoints(race);
                checkpointOrder = new CheckpointOrderModel();
                checkpointOrder.AddCheckpointOrderDB(timer.CurrentCheckpointId, 1);
                timer.Start();
                timer.AddRuntime(400, timer.GetFirstCheckpointId());
                intermediate = new RaceIntermediateModel(timer.CurrentCheckpointId, checkpointOrder.ID, timer.CheckpointRuntimes[timer.CurrentCheckpointId].First().Key);
                intermediate.Save();
            });

            When("we want to connect athletes to startnumbers", () =>
            {
                RaceIntermediateModel.MergeAthletes(race.RaceId);
            });

            Then("athletes should be connected to raceintermediate", () =>
            {
                RaceIntermediateModel.GetRaceintermediatesForRace(race.RaceId).First().AthleteId.ShouldNotBeNull();

            });
        }
コード例 #2
0
ファイル: TimeStartnumberModel.cs プロジェクト: heinek/ITimeU
 /// <summary>
 /// Adds the startnumber.
 /// </summary>
 /// <param name="cpId">The cp id.</param>
 /// <param name="startNr">The start nr.</param>
 /// <param name="runtimeint">The runtimeint.</param>
 /// <returns></returns>
 public void AddStartnumber(int cpId, int startNr, int runtimeint)
 {
     var checkpointOrderId = CheckpointOrder.AddCheckpointOrderDB(cpId, startNr);
     if (checkpointOrderId == 0) return;
     var runtimeId = Timer.AddRuntime(runtimeint, cpId).Id;
     RaceIntermediateModel raceIntermediate = new RaceIntermediateModel(cpId, checkpointOrderId, runtimeId);
     raceIntermediate.Save();
     CheckpointIntermediates[CurrentCheckpointId].Add(raceIntermediate);
 }
コード例 #3
0
ファイル: RaceIntermediateTest.cs プロジェクト: heinek/ITimeU
 public void TestSetup()
 {
     club = new ClubModel("Test IK");
     eventModel = new EventModel("TestEvent", DateTime.Today);
     eventModel.Save();
     athlete = new AthleteModel("Tester", "Test");
     athlete.StartNumber = 1;
     athlete.Club = club;
     athlete.SaveToDb();
     race = new RaceModel("TestRace", DateTime.Today);
     race.EventId = eventModel.EventId;
     race.Save();
     checkpointOrder = null;
     intermediate = null;
     checkpoint = null;
 }
コード例 #4
0
ファイル: TimeMergerModel.cs プロジェクト: heinek/ITimeU
        public static RaceIntermediateModel Merge(int checkpointId, int checkpointOrderId, int runtimeId)
        {
            var raceIntermediateModel = new RaceIntermediateModel(checkpointId, checkpointOrderId, runtimeId);
            if (raceIntermediateModel.Save())
            {
                var cpo = CheckpointOrderModel.GetById(checkpointOrderId);
                cpo.IsMerged = true;
                cpo.Update();

                var runtime = RuntimeModel.getById(runtimeId);
                runtime.IsMerged = true;
                runtime.Update();

                return raceIntermediateModel;
            }
            return null;
        }