private async void AddButton_OnClick(object sender, RoutedEventArgs e) { var result = await _personDialog.ShowAsync(); if (result == ContentDialogResult.Primary) { var name = _personDialog.Name; var userData = _personDialog.UserData; if (_person == null) { var person = new Person() { Name = name, UserData = userData }; if (await new ApiService().CreatePerson(_group, person)) { await LoadPerson(); } } else { _person.Name = name; _person.UserData = userData; if (await new ApiService().UpdatePerson(_group, _person)) { await LoadPerson(); } } Clear(); } }
private async void addPersonButton_Click(object sender, RoutedEventArgs e) { testInternetConnection(); if (internetConnection) { thisPerson = new Person(); var result = await PersonDialog.ShowAsync(); // Value 1 indicates primary button was selected by the user, which adds a new Person if ((int)result == 1) { //Apply the Data showProgressDialog("Apply the Data..."); thisPerson.Name = PersonNameInput.Text; thisPerson.Relation = PersonRelationInput.Text; thisPerson.RiskFactor = (int)riskSlider.Value; thisPerson.PatientId = PatientId; //Upload Person Info progressDialog.Content = "Upload Person Info..."; await AzureDatabaseService.UploadPersonInfo(thisPerson); thisPerson = await AzureDatabaseService.GetPersonFromNameAndRelation(thisPerson.Name, thisPerson.Relation, thisPerson.PatientId); //statusTextBlock.Text = "thisPerson.Id = " + thisPerson.Id; //Upload Face Info progressDialog.Content = "Upload Faces and Images..."; foreach (Face face in addFaceList) { face.PersonId = thisPerson.Id; } await AzureDatabaseService.UploadFaceInfo(thisPerson.Id, addFaceList); foreach (Face face in deleteFaceList) { await AzureDatabaseService.DeleteFace(face); } //Reload Persons List loadPersonsAndCheckEnquiry(); //Add a Person Finished! progressDialog.Content = "Add a Person Finished !"; progressDialog.IsPrimaryButtonEnabled = true; } //end result == 1 } //end internetConnection initializePersonInfoDialog(); }//end addPersonButton_Click
}//end addPersonButton_Click private async void WarningImage_Tapped(object sender, TappedRoutedEventArgs e) { //get the stranger info thisPerson = await AzureDatabaseService.GetOnePersonFromId(unfinishedWarningList[0].PersonId); defaultImage.Source = await AzureBlobService.DisplayImageFile(thisPerson.DefaultImageAddress); familiarRadioButton.IsChecked = thisPerson.IsFamiliar; strangeRadioButton.IsChecked = !thisPerson.IsFamiliar; //Update Faces Faces.Clear(); ObservableCollection <Face> faces = await AzureDatabaseService.GetFaceList(thisPerson.Id); foreach (Face face in faces) { face.Image = await AzureBlobService.DisplayImageFile(face.ImageAddress); Faces.Add(face); } var result = await PersonDialog.ShowAsync(); // Value 1 indicates primary button was selected by the user, which modify the Person if ((int)result == 1) { //Enable the Update of Person Info //Apply the Data showProgressDialog("Apply the Data..."); thisPerson.Name = PersonNameInput.Text; thisPerson.Relation = PersonRelationInput.Text; thisPerson.RiskFactor = (int)riskSlider.Value; //Upload Person Info progressDialog.Content = "Update Person Info..."; await AzureDatabaseService.UpdatePersonInfoWithId(thisPerson); //Upload Face Info progressDialog.Content = "Upload Faces and Images..."; foreach (Face face in addFaceList) { face.PersonId = thisPerson.Id; } await AzureDatabaseService.UploadFaceInfo(thisPerson.Id, addFaceList); foreach (Face face in deleteFaceList) { await AzureDatabaseService.DeleteFace(face); } //TODO: Cannot update the default image address in the Person //Operate the Enquiry Info progressDialog.Content = "Operate the Enquiry Info..."; Warning thisWarning = unfinishedWarningList[0]; thisWarning.IsFinished = true; thisWarning.IsFamiliar = thisPerson.IsFamiliar; await AzureDatabaseService.UpdateWarningEnquiryWithId(thisWarning); //Reload Persons List loadPersonsAndCheckEnquiry(); //Add a Person Finished! progressDialog.Content = "Operate the Enquiry Finished !"; progressDialog.IsPrimaryButtonEnabled = true; }//end result == 1 initializePersonInfoDialog(); }
private async void personGridView_ItemClick(object sender, ItemClickEventArgs e) { //Update Person Info thisPerson = e.ClickedItem as Person; familiarRadioButton.IsChecked = thisPerson.IsFamiliar; strangeRadioButton.IsChecked = !thisPerson.IsFamiliar; PersonNameInput.Text = thisPerson.Name; PersonRelationInput.Text = thisPerson.Relation; if (thisPerson.DefaultImageAddress != null) { defaultImage.Source = thisPerson.DefaultIcon; //await AzureBlobService.DisplayImageFile(thisPerson.DefaultImageAddress); } else { defaultImage.Source = nullBitmapImage; } riskSlider.Value = thisPerson.RiskFactor; //Update Faces Faces.Clear(); ObservableCollection <Face> faces = await AzureDatabaseService.GetFaceList(thisPerson.Id); foreach (Face face in faces) { face.Image = await AzureBlobService.DisplayImageFile(face.ImageAddress); Faces.Add(face); } //Show the Person Info Dialog var result = await PersonDialog.ShowAsync(); // Value 1 indicates primary button was selected by the user, which modify a new Person if ((int)result == 1) { //Enable the Update of Person Info //Apply the Data showProgressDialog("Apply the Data..."); thisPerson.Name = PersonNameInput.Text; thisPerson.Relation = PersonRelationInput.Text; thisPerson.RiskFactor = (int)riskSlider.Value; //Upload Person Info progressDialog.Content = "Update Person Info..."; await AzureDatabaseService.UpdatePersonInfoWithId(thisPerson); //Upload Face Info progressDialog.Content = "Upload Faces and Images..."; foreach (Face face in addFaceList) { face.PersonId = thisPerson.Id; Faces.Remove(face); } ObservableCollection <Face> newAddFaceList = await AzureDatabaseService.UploadFaceInfo(thisPerson.Id, addFaceList); foreach (Face face in addFaceList) { Faces.Add(face); } foreach (Face face in deleteFaceList) { await AzureDatabaseService.DeleteFace(face); } try { await AzureDatabaseService.UpdateFaceIsDefault(thisPerson.Id, Faces); } catch { } //Reload Persons List loadPersonsAndCheckEnquiry(); //Add a Person Finished! progressDialog.Content = "Update a Person Finished !"; progressDialog.IsPrimaryButtonEnabled = true; }//end result == 1 initializePersonInfoDialog(); deletePersonButton.IsEnabled = true; }