示例#1
0
        private async Task OnAddFriendClick()
        {
            var userDialogs = Acr.UserDialogs.UserDialogs.Instance;
            var input       = await userDialogs.PromptAsync("Add new friend", "Enter your friend name", "Add", "Cancel");

            if (input.Ok)
            {
                string toastMessage = "something goes wrong";
                var    result       = await ApiClient.AddFriendByUsername(input.Text);

                if (result.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    toastMessage = $"Not found {input.Text}";
                }
                else if (result.ResultContent != null)
                {
                    if (result.ResultContent.Status == 0)
                    {
                        toastMessage = "Invited";
                    }
                    else
                    {
                        toastMessage = "Accepted";
                    }
                }
                else if (result.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                {
                    toastMessage = "Unauthorized";
                }

                userDialogs.Toast(toastMessage);
            }
        }