/// <summary>
        /// Edit a given activity
        /// </summary>
        /// <param name="activityId">The Strava ID of the activity you want to edit.</param>
        /// <param name="name"></param>
        /// <returns></returns>
        public async Task PutUpdate(string activityId, string name, bool commute, bool isPrivate, string gearID)
        {
            try
            {
                int commuteAsInt   = commute ? 1 : 0;
                int isPrivateAsInt = isPrivate ? 1 : 0;

                var accessToken = await _settingsService.GetStoredStravaAccessTokenAsync();

                string postUrl = $"{Endpoints.Activity}/{activityId}?name={WebUtility.UrlEncode(name)}&commute={commuteAsInt}&private={isPrivateAsInt}";
                if (!string.IsNullOrEmpty(gearID))
                {
                    postUrl += $"&gear_id={WebUtility.UrlEncode(gearID)}";
                }

                postUrl += $"&access_token={accessToken}";

                await _stravaWebClient.SendPutAsync(new Uri(postUrl));
            }
            catch (Exception ex)
            {
#if !DEBUG
                _errorMessage.Clear();
                _errorMessage.AppendLine($"StravaActivityService.PutUpdate - activityId {activityId} - name {name} - commute {commute} - isPrivate {isPrivate} - gearID {gearID}");
                _errorMessage.AppendLine(ex.Message);
                ServiceLocator.Current.GetInstance <IGoogleAnalyticsService>().Tracker.SendException(_errorMessage.ToString(), false);
#endif
            }
        }
예제 #2
0
        /// <summary>
        /// Edit a given activity
        /// </summary>
        /// <param name="activityId">The Strava ID of the activity you want to edit.</param>
        /// <param name="name"></param>
        /// <returns></returns>
        public async Task PutUpdate(string activityId, string name, bool commute, bool isPrivate, string gearID)
        {
            try
            {
                int commuteAsInt   = commute ? 1 : 0;
                int isPrivateAsInt = isPrivate ? 1 : 0;

                var accessToken = await _settingsService.GetStoredStravaAccessTokenAsync();

                string postUrl = $"{Endpoints.Activity}/{activityId}?name={WebUtility.UrlEncode(name)}&commute={commuteAsInt}&private={isPrivateAsInt}";
                if (!string.IsNullOrEmpty(gearID))
                {
                    postUrl += $"&gear_id={WebUtility.UrlEncode(gearID)}";
                }

                postUrl += $"&access_token={accessToken}";

                await _stravaWebClient.SendPutAsync(new Uri(postUrl));
            }
            catch (Exception ex)
            {
                string title = $"StravaActivityService.PutUpdate - activityId {activityId} - name {name} - commute {commute} - isPrivate {isPrivate} - gearID {gearID}";
                _logService.LogException(title, ex);
            }
        }