예제 #1
0
 private async Task WorkoutRemove(IWorkout workout, PlaylistModel list)
 {
     list.Workouts.Remove(list.Workouts.First(w => w.Id == workout.Id && w.WorkoutType == workout.WorkoutType));
     var type = workout.WorkoutType.ToString();
     await db_.Database.Table <ListWorkoutDBModel>().DeleteAsync(s =>
                                                                 s.PlaylistId == list.Playlist.Id && s.WorkoutId == workout.Id && s.WorkoutType.Equals(type));
 }
예제 #2
0
        public async Task ScheduleReocurring(IWorkout workout, DateTime when, TimeSpan interval)
        {
            Notification toInsert;

            if (when < nextToPop_?.TriggerTime)
            {
                toInsert               = nextToPop_;
                nextToPop_.Workout     = workout;
                nextToPop_.TriggerTime = when;
                nextToPop_.Id          = await NextScheduleId;
                nextToPop_.Next        = interval;
            }
            else
            {
                var id = await NextScheduleId;
                toInsert = new Notification
                {
                    Id          = id,
                    Next        = interval,
                    TriggerTime = when,
                    Workout     = workout
                };
            }
            await AddScheduleToDb(toInsert);

            if (nextToPop_ == null)
            {
                await ReloadSchedule();
            }
        }
예제 #3
0
        // TODO: Once an erg has been established with the server (using an ititiating hub call, serial number shouldn't be needed for each communication because the channel should be open and unique
        // TODO: Return intentional success/failure on every communication with the Erg for reporting
        public async Task DefineWorkout(string serialNumber, IWorkout workout)
        {
            if (string.IsNullOrWhiteSpace(serialNumber))
            {
                _logger.LogWarning("When requested to send a workout to the Erg, the serial number was null. Returning without sending.");
                return;
            }

            if (workout == null)
            {
                _logger.LogWarning("When requested to send a workout to the Erg, the workout was null. Returning without sending.");
                return;
            }

            bool workoutSet = false;

            if (_pmService.IsReadyToProgramWorkout(serialNumber))
            {
                // Send the workout
                _pmService.SetWorkout(serialNumber, workout);
                workoutSet = true;
            }

            if (!workoutSet)
            {
                // Send a failure report back to the server
            }
        }
예제 #4
0
    void IObserver.OnNotify(object parametr, GAME_EVENTS notificationName)
    {
        switch (notificationName)
        {
        case GAME_EVENTS.ButtonHandlerLoaded:
            StartBehaviour();
            break;

        case GAME_EVENTS.WordsEnded:
            print("ScoreValue = " + GetCorrectAnswers());
            WordsEndedBehaviour();
            break;

        case GAME_EVENTS.CorrectAnswer:
            AddWorkoutProgress(currentWord, subWorkout);
            if (currentWord.AllWorkoutDone())
            {
                currentWord.AddLicenseLevel();
            }
            break;

        case GAME_EVENTS.BuildTask:
            IWorkout workout = parametr as IWorkout;
            subWorkout  = workout.WorkoutName;
            currentWord = workout.GetCurrentWord();
            break;
        }
    }
예제 #5
0
 public App()
 {
     InitializeComponent();
     Scorecard    = new ScorecardService();
     TopScores    = new RecordKeeper(Properties);
     WorkoutState = new WorkoutStateService();
     Workouts     = new WorkoutRepository();
     MainPage     = new NavigationPage(new MainPage());
 }
예제 #6
0
 private async Task WorkoutAttach(IWorkout workout, PlaylistModel list)
 {
     list.Workouts.Add(workout);
     await db_.Database.InsertAsync(new ListWorkoutDBModel
     {
         PlaylistId  = list.Playlist.Id,
         WorkoutId   = workout.Id,
         WorkoutType = workout.WorkoutType.ToString()
     });
 }
예제 #7
0
        public async Task EditSchedule(int id, IWorkout workout, DateTime when, TimeSpan interval)
        {
            var schedule = await ScheduleDBModel.FromDB(id, database_);

            schedule.WorkoutId   = workout.Id;
            schedule.WorkoutType = workout.WorkoutType;
            schedule.When        = when;
            schedule.Interval    = interval;
            await schedule.AddOrUpdate(database_);

            await ReloadSchedule();
        }
예제 #8
0
 public pwx GetExtendedWorkoutData(IAthlete athlete, IWorkout workout)
 {
     var stm = new MemoryStream();
     var stw = new StreamWriter(stm);
     var xmlData =
         workout.ExtendedPwXmlNode =
             soapClient.GetExtendedWorkoutDataForAccessibleAthlete(athlete.TPData.LoginName,
                 athlete.TPData.LoginPassword, athlete.TPData.PersonID, workout.TPWorkoutID);
     stw.Write(xmlData.OuterXml);
     stw.Flush();
     stm.Position = 0;
     var ser = new XmlSerializer(typeof (pwx));
     var pwxObj = ser.Deserialize(stm);
     workout.pwxData = pwxObj;
     return pwxObj as pwx;
 }
 public static IWorkout MapExtendedCycleWorkout(pwx pwx, IWorkout shortWorkout)
 {
     pwxWorkout pwxWo = pwx.workout[0];
     IAthlete athlete = new Athlete();
     athlete.FTBikePower = 231;
     shortWorkout.TrainingStressScore = pwxWo.summarydata.tss;
     ICycleWorkout cycleWorkout = shortWorkout as ICycleWorkout;
     if (cycleWorkout == null)
         return shortWorkout;
     PWXDataExtractor dataExtractor = new PWXDataExtractor(pwx);
     var workoutSamples = dataExtractor.ExtractData();
     WorkoutSamplesCalculator calc = new WorkoutSamplesCalculator(workoutSamples, athlete);
     cycleWorkout.IntensityFactor = calc.CalcualteIntensityFactor();
     cycleWorkout.NormalizedPower = (int)calc.GetNormalizedPower();
     
     return shortWorkout;
 }
예제 #10
0
        public pwx GetExtendedWorkoutData(IAthlete athlete, IWorkout workout)
        {
            var stm     = new MemoryStream();
            var stw     = new StreamWriter(stm);
            var xmlData =
                workout.ExtendedPwXmlNode =
                    soapClient.GetExtendedWorkoutDataForAccessibleAthlete(athlete.TPData.LoginName,
                                                                          athlete.TPData.LoginPassword, athlete.TPData.PersonID, workout.TPWorkoutID);

            stw.Write(xmlData.OuterXml);
            stw.Flush();
            stm.Position = 0;
            var ser    = new XmlSerializer(typeof(pwx));
            var pwxObj = ser.Deserialize(stm);

            workout.pwxData = pwxObj;
            return(pwxObj as pwx);
        }
예제 #11
0
        /// <inheritdoc />
        public void SetWorkout(string serialNumber, IWorkout workout)
        {
            if (string.IsNullOrWhiteSpace(serialNumber))
            {
                _logger.LogError("Serial number must not be null. No workout has been set.");
                return;
            }

            if (workout == null)
            {
                _logger.LogError("Workout must not be null. No workout has been set.");
                return;
            }

            // Determine which type of workout based on intervals defined and set it


            throw new NotImplementedException();
        }
예제 #12
0
        public static IWorkout MapExtendedCycleWorkout(pwx pwx, IWorkout shortWorkout)
        {
            pwxWorkout pwxWo   = pwx.workout[0];
            IAthlete   athlete = new Athlete();

            athlete.FTBikePower = 231;
            shortWorkout.TrainingStressScore = pwxWo.summarydata.tss;
            ICycleWorkout cycleWorkout = shortWorkout as ICycleWorkout;

            if (cycleWorkout == null)
            {
                return(shortWorkout);
            }
            PWXDataExtractor dataExtractor = new PWXDataExtractor(pwx);
            var workoutSamples             = dataExtractor.ExtractData();
            WorkoutSamplesCalculator calc  = new WorkoutSamplesCalculator(workoutSamples, athlete);

            cycleWorkout.IntensityFactor = calc.CalcualteIntensityFactor();
            cycleWorkout.NormalizedPower = (int)calc.GetNormalizedPower();

            return(shortWorkout);
        }
예제 #13
0
 public Coach()
 {
     workoutBuilder = new FitnessExercices();
 }
예제 #14
0
 private Task PostponeWorkout(IWorkout workout)
 {
     return(DependencyService.Get <Schedule.NotificationManager>().Schedule(workout, DateTime.Now + TimeSpan.FromMinutes(5)));
 }
예제 #15
0
 public NutritionRepository()
 {
     _workoutRepository = new WorkoutRepository();
 }
예제 #16
0
 public RegistrationRepository()
 {
     _workoutRepository   = new WorkoutRepository();
     _nutritionRepository = new NutritionRepository();
 }
예제 #17
0
 public WorkoutController(IWorkout repository)
 {
     this.repository = repository;
 }
예제 #18
0
 public NutritionRepository()
 {
     _workoutRepository = new WorkoutRepository();
 }
예제 #19
0
 public Task Schedule(IWorkout workout, DateTime when) =>
 ScheduleReocurring(workout, when, TimeSpan.Zero);
예제 #20
0
 public RegistrationRepository()
 {
     _workoutRepository = new WorkoutRepository();
     _nutritionRepository = new NutritionRepository();
 }
예제 #21
0
 protected override Task OnInitializedAsync()
 {
     workout      = new Spartacus();
     workoutState = WorkoutState.NotStarted;
     return(Task.CompletedTask);
 }
예제 #22
0
 public WorkoutController(IWorkout repository)
 {
     this.repository = repository;
 }