示例#1
0
        private async void Participate()
        {
            if (SelectedAnotherRoom == null)
            {
                return;
            }

            var resp = await _httpManager.PutAsync <bool>($"api/Rooms/{SelectedAnotherRoom.Id}/Participate");

            if (resp.Error != null)
            {
                ShowNotification(resp.Error.ErrorDescription);
                return;
            }
        }
        public async Task <CreateLeaderboardResponseCode> CreateLeaderboardAsync(string name, LeagueTypesEnum leagueType, ParticipantModel creator)
        {
            if (creator == null)
            {
                return(CreateLeaderboardResponseCode.UnknownError);
            }

            creator.IsAdmin = true;
            var leaderboard = new LeaderboardModel()
            {
                LeagueType   = leagueType,
                Name         = name,
                Participants = new ObservableCollection <ParticipantModel>()
                {
                    creator
                }
            };
            var response = await _httpManager.PutAsync <CreateLeaderboardResponseCode>(ApiConstants.LeaderboardsURL, leaderboard);

            return(response);
        }
示例#3
0
        public async Task <HttpResponseMessage> PutAndWait(string id, string key, dynamic value, List <string> compositeKey = null, TimeSpan?expireTime = null, TimeSpan?idleTime = null, bool?performAsync = false)
        {
            //I have to convert the object now, because text/plain does not convert to json on httpManager. But if it's already a string, I'm not going to serialize
            string jsonValue = null;

            try
            {
                if (!(value is string))
                {
                    jsonValue = JsonConvert.SerializeObject(value);
                }
            }
            catch (Exception)
            {
                //supress
            }

            return(await _httpManager.PutAsync(
                       $"/{_prefixUrl}{Urlfy(id)}/{GenerateKey(key, compositeKey)}", jsonValue ?? value,
                       GetRequestHeaders(expireTime, idleTime, performAsync),
                       ServerPool.Next().ToString(), mediaType : "text/plain"));
        }
 public Task <User> UpdateAsync(User user)
 {
     return(_httpManager.PutAsync <User>($"userApi/User/{user.Id}", user));
 }