public string PushTrainingsToSportsTracker(Training training)
        {
            ProductivityTools.SportsTracker.SDK.Model.Training sdkTraining = new ProductivityTools.SportsTracker.SDK.Model.Training();
            sdkTraining.StartDate = training.Start;
            sdkTraining.Distance  = decimal.ToDouble(training.Distance);
            var trainingMap = TrainingMapConfiguration.GetTraining(training.Sport);

            sdkTraining.TrainingType      = trainingMap.SportsTrackerTrainingType;
            sdkTraining.Duration          = TimeSpan.FromSeconds(training.Duration);
            sdkTraining.Description       = $"{trainingMap.Name} {training.Name}";
            sdkTraining.EnergyConsumption = Convert.ToInt32(training.Calories);
            Console.WriteLine(sdkTraining.EnergyConsumption);
            sdkTraining.SharingFlags = 19;

            var result = this.SportTrackerSdk.AddTraining(sdkTraining, training.Gpx, training.Pictures);

            return(result);
        }
        public void AddTraining(string account,
                                ProductivityTools.SportsTracker.SDK.Model.Training stTraining,
                                byte[] gpx,
                                List <ProductivityTools.SportsTracker.SDK.Model.TrainingImage> images)
        {
            Training training = new Training();

            training.Account     = account;
            training.Application = "SportsTracker";
            training.Calories    = stTraining.EnergyConsumption;
            //  training.Comment = stTraining.Description;
            training.Distance       = Convert.ToDecimal(stTraining.Distance);
            training.Duration       = Convert.ToInt32(stTraining.Duration.TotalSeconds);
            training.Start          = stTraining.StartDate;
            training.End            = training.Start.AddSeconds(training.Duration);
            training.ExternalIdList = new Dictionary <string, string>();
            training.ExternalIdList.Add("SportsTracker", stTraining.WorkoutKey);
            training.Name   = stTraining.Description;
            training.Source = "TrainingLog.SportsTracker.Cmdlet";
            var trainingMap = TrainingMapConfiguration.GetTraining(stTraining.TrainingType);

            training.Sport          = trainingMap.TrainingLogTrainingType;
            training.AverageSpeed   = stTraining.AverageSpeed;
            training.ExternalIdList = new Dictionary <string, string>();
            training.ExternalIdList.Add("SportsTracker", stTraining.WorkoutKey);

            training.Gpx = gpx;

            training.Pictures = new List <byte[]>();
            foreach (var image in images)
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    image.Stream.CopyTo(ms);
                    training.Pictures.Add(ms.ToArray());
                }
            }

            TrainingLogSdk.PostTraining(training);
        }