private async void Save_Clicked(object sender, EventArgs e) { Button button = (Button)sender; button.IsEnabled = false; try { var IsValid = validateUserProfile(); if (IsValid && !IsFromUpdate) { var addItemRequest = await SaveNewProfileDetails(); var res = await userProfileViewModel.SaveProfile(addItemRequest); if (res != null) { if (res.Code == 0) { InvoceCallback(); DisplayAlert("Message", "Your profile completed!", null, "OK"); Application.Current.MainPage = new NavigationPage(new MainPage()); } else { await DisplayAlert("Message", "Completing profile Failed. Please try again", null, "OK"); } } else { await DisplayAlert("Message", "Completing profile Failed. Please try again", null, "OK"); } } else if (IsValid && IsFromUpdate) { var updateItemRequest = await SaveEditProfileDetails(); var res = await userProfileViewModel.UpdateProfile(updateItemRequest); if (res != null) { if (res.Code == 0) { InvoceCallback(); DisplayAlert("Message", "Profile updated successfully!", null, "OK"); await Navigation.PopModalAsync(); } else { await DisplayAlert("Message", "Updating profile Failed. Please try again", null, "OK"); } } else { await DisplayAlert("Message", "Updating profile Failed. Please try again", null, "OK"); } } } catch (Exception ex) { } finally { button.IsEnabled = true; } }