예제 #1
0
        public static async Task <HttpResponseMessage> InvitePlayer(InvitePlayerRequest invitePlayer)
        {
            var jsonObject = JsonConvert.SerializeObject(invitePlayer);
            var content    = new StringContent(jsonObject.ToString(), Encoding.UTF8, "application/json");

            return(await _httpClient.PostAsync(
                       string.Format(ApiConstants.InvitePlayerEndpoint, invitePlayer.ClubId),
                       content));
        }
예제 #2
0
        private void InvitePlayer_Click(object sender, System.EventArgs e, int playerId, int clubId)
        {
            AlertDialog.Builder alert       = new AlertDialog.Builder(_activity);
            EditText            description = new EditText(_activity);

            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent,
                                                                         LinearLayout.LayoutParams.WrapContent);

            lp.LeftMargin  = 60;
            lp.RightMargin = 60;
            description.LayoutParameters = lp;
            alert.SetView(description);
            alert.SetTitle("Покана на играч");
            alert.SetMessage("Добавете описание към поканата");
            alert.SetPositiveButton("Покани", async(senderAlert, args) =>
            {
                InvitePlayerRequest invitePlayer = new InvitePlayerRequest
                {
                    PlayerId    = playerId,
                    ClubId      = clubId,
                    Description = description.Text
                };

                HttpResponseMessage invitePlayerHttpResponse = await RestManager.InvitePlayer(invitePlayer);

                if (invitePlayerHttpResponse.IsSuccessStatusCode)
                {
                    Toast.MakeText(_activity, "Играчът е поканен!", ToastLength.Short).Show();
                }
            });

            alert.SetNegativeButton("Отказ", (senderAlert, args) =>
            {
                return;
            });

            Dialog dialog = alert.Create();

            dialog.Show();
        }