private async Task <bool> ImportFaceToServerAsync(Person person) { var response = await RestfulClient.CreatePerson(person); if (response.ReturnCode == 200) { return(true); } else { return(false); } }
private async void BtnAddFace_ClickAsync(object sender, EventArgs e) { switch (captureImageType) { case CaptureImageType.NewPerson: case CaptureImageType.NewPersonCaptured: { if (cropedFace != null) { try { var person = new Person(txtUsrename.Text, txtDetail.Text, new WebEntity.Face(Convert.ToBase64String(cropedFace))); TxtErrorMessage.Text = ""; var response = await RestfulClient.CreatePerson(person); if (response.ReturnCode == 200) { TxtErrorMessage.Text = "Success"; } else { TxtErrorMessage.Text = response.Message; return; } } catch (Exception ex) { TxtErrorMessage.Text = ex.Message; return; } } else { MessageBox.Show("Please capture face first.", "No face found", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } break; case CaptureImageType.CurrentPerson: case CaptureImageType.UpdatePerson: case CaptureImageType.UpdatePersonCaptured: { if (selectedPerson != null) { selectedPerson.Name = txtUsrename.Text; selectedPerson.Detail = txtDetail.Text; if (cropedFace != null) { selectedPerson.Face.FaceData = Convert.ToBase64String(cropedFace); } } TxtErrorMessage.Text = ""; var response = await RestfulClient.UpdatePerson(selectedPerson); if (response.ReturnCode == 200) { TxtErrorMessage.Text = "Success"; } else { TxtErrorMessage.Text = response.Message; return; } } break; } UpdateFlow(FlowAction.Save); }