Example #1
0
        public async void SavePerson()
        {
            if (!FieldsAreFilled())
            {
                ToastUtil.ShowToast("All fields must be filled!");

                return;
            }

            PersonObject.ImageName = PersonObject.PersonFirstName + PersonObject.PersonLastName + ".jpg";
            PersonObject.Score     = 0;

            await CloudStorageService.SaveBlockBlob(takenPhoto, PersonObject.ImageName);

            PersonObject.ImageContentUri = CloudStorageService.GetImageUri(_personObject.ImageName);

            try
            {
                UserDialogs.Instance.ShowLoading("Loading", MaskType.Black);

                PersonObject = await _restService.CreateImageObject(PersonObject);
            }

            catch (ManagerException creationException)
            {
                UserDialogs.Instance.HideLoading();

                ToastUtil.ShowToast(creationException.ErrorCode);

                return;
            }

            try
            {
                var status = await _restService.InsertUserIntoRecognition(PersonObject);

                var features = await _restService.GetFaceFeatures(PersonObject);

                var insertedFeatures = await _restService.InsertFaceFeatures(features);
            }

            catch (ManagerException recognitionException)
            {
                UserDialogs.Instance.HideLoading();

                ToastUtil.ShowToast(recognitionException.ErrorCode);

                return;
            }

            SaveProperties();

            UserDialogs.Instance.HideLoading();

            NavigateToHomePage();
        }