Exemple #1
0
        async void Handle_DeleteTapped(object sender, EventArgs e)
        {
            UserAPI        userAPI      = new UserAPI();
            HttpStatusCode photoUpdated = await userAPI.DeleteUserPhoto();

            switch (photoUpdated)
            {
            case HttpStatusCode.OK:
                DeletePhotoCell.IsEnabled = false;
                NoPhotoLabel.IsVisible    = true;
                imageView.Source          = null;
                UserController.Instance.ProfilePhotoSource = null;
                UserController.Instance.mainPageController.updateMenuPhoto();
                await DisplayAlert("",
                                   "User photo successfully deleted",
                                   "OK");

                break;

            case HttpStatusCode.BadRequest:
                await DisplayAlert("",
                                   "User photo delete failed (400)",
                                   "OK");

                break;

            case HttpStatusCode.ServiceUnavailable:
                await DisplayAlert("",
                                   "Server unavailable, check connection",
                                   "OK");

                break;

            case HttpStatusCode.Unauthorized:
                await DisplayAlert("",
                                   "Unauthorised to modify photo",
                                   "OK");

                break;

            case HttpStatusCode.InternalServerError:
                await DisplayAlert("",
                                   "Server error, please try again (500)",
                                   "OK");

                break;
            }
        }