public override void ViewDidLoad() { base.ViewDidLoad(); userEditInfoTableView.RowHeight = 120; userEditInfoTableView.ContentInset = new UIEdgeInsets(100, 0, 0, 0); userEditInfoTableView.TableFooterView = new UIView(CGRect.Empty); // Remove empty cells GetTableViewData(User, SharedImage, this); AddBackground(); saveButton = new UIBarButtonItem() { Title = "Save" }; saveButton.Clicked += async(sender, e) => { LoadingOverlay.ShowOverlay(this.View); var listUserEditedInfo = EditProfileSharedData.EditedUserInfo; string userFirstName = listUserEditedInfo[0]; string userLastName = listUserEditedInfo[1]; string userEmail = listUserEditedInfo[2]; string userPassword = listUserEditedInfo[3]; if (string.IsNullOrEmpty(userFirstName) || string.IsNullOrEmpty(userLastName)) { LoadingOverlay.RemoveOverlay(); DisplayAlertMessage("All fields are required to fill in"); return; } // If email or password do not meet requirements if (string.IsNullOrWhiteSpace(userEmail)) { LoadingOverlay.RemoveOverlay(); DisplayAlertMessage("Email is required to fill in"); return; } if (!Validation.ValidationResult(userEmail, "email")) { LoadingOverlay.RemoveOverlay(); DisplayAlertMessage(Validation.Message); return; } if (!string.IsNullOrEmpty(userPassword)) { if (!Validation.ValidationResult(userPassword, "password")) { LoadingOverlay.RemoveOverlay(); DisplayAlertMessage(Validation.Message); return; } } saveButton.Enabled = false; var userRepository = new UsersRepository(); var updatedUser = new UsersModel() { Id = User.Id, FirstName = userFirstName, LastName = userLastName, Email = userEmail.ToLower(), Password = userPassword, Avatar = await ConvertImage.ConvertImageToBinary(SharedImage), LoginProvider = User.LoginProvider, CreatedAt = User.CreatedAt }; // Call REST service to send Json data RestService rs = new RestService(); // Get Json data from server in JsonResponseModel format Task <UsersModel> jsonResponeTask = rs.UserLoginAndRegisterJson(updatedUser, "update"); // If there was an error in PostJsonDataAsync class, display message if (jsonResponeTask == null) { LoadingOverlay.RemoveOverlay(); DisplayAlertMessage(rs.Message); return; } // Get user id from Json after login or display an error // Create instance of JsonResponseModel and pass jsonResponeTask there var jsonResponse = await jsonResponeTask; // Get user id from Json after update or display an error if (jsonResponse.Status == "Error") { LoadingOverlay.RemoveOverlay(); DisplayAlertMessage(jsonResponse.Message); return; } else { Console.WriteLine(jsonResponse.Message); } await userRepository.UpdateUser(updatedUser); // Update in local database User = updatedUser; // Send back to UserProfileViewController to update data there LoadingOverlay.RemoveOverlay(); saveButton.Enabled = true; this.NavigationController.PopViewController(true); }; this.NavigationItem.SetRightBarButtonItem(saveButton, true); }