public async void CallSearchData() { LstEvidClients.Clear(); EvidenciasModel SearchEvidences = new EvidenciasModel(); SearchServices searchService = new SearchServices(); try { if (TypeDocSelected == null && TypeDocSelected.id < 0) { await Application.Current.MainPage.DisplayAlert("", "Seleccione un tipo de documento", "Ok"); isProcessing = false; return; } if (string.IsNullOrEmpty(Identification)) { await Application.Current.MainPage.DisplayAlert("", "Ingrese la identificación del cliente", "Ok"); isProcessing = false; return; } SearchEvidences.typeDoc = TypeDocSelected.id; SearchEvidences.identifClient = this.Identification; Evidences = await searchService.SearchData(SearchEvidences); this.NameClient = Evidences.nameClient; if (Evidences.idTercero > 0) { LstEvidClients.Add(new EvidenciasModel { nameClient = Evidences.nameClient, identifClient = Evidences.identifClient, idTercero = Evidences.idTercero, sigla = TypeDocSelected.nameAux, holder = true }); } else { MainViewModel.GetInstance().AddClient = new AddClientViewModel(); MainViewModel.GetInstance().AddClient.IdTypeDoc = TypeDocSelected.id; MainViewModel.GetInstance().AddClient.Identification = this.Identification; MainViewModel.GetInstance().AddClient.DataNewClient = true; await Application.Current.MainPage.Navigation.PushModalAsync(new AddClientPage()); } withData = true; isProcessing = false; } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("TakePicture SearchData", ex.Message, "Ok"); } }
public async void TakePicture() { try { if (ClientSelected != null && ClientSelected.idTercero > 0) { imgByte = null; await CrossMedia.Current.Initialize(); if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { await App.Current.MainPage.DisplayAlert("Error Cámara", "La cámara del dispositivo no esta disponible.", "Aceptar"); } this.file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { Directory = "Sample", Name = this.Identification + ".jpg", PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small }); if (this.file != null) { Imagen = ImageSource.FromStream(() => { MemoryStream stream = (MemoryStream)file.GetStreamWithImageRotatedForExternalStorage(); return(stream); }); imgByte = ConvertPictureBytes(file.Path); Imagen = file.Path; } if (file == null) { Imagen = "ic_nodispon"; } ObservableCollection <EvidenciasModel> lsTemp = new ObservableCollection <EvidenciasModel>(); ItemListSelected = LstEvidClients.FirstOrDefault(x => x.idTercero == ClientSelected.idTercero); ItemListSelected.image = this.Imagen; ItemListSelected.evidencia1 = this.imgByte; foreach (var item in LstEvidClients) { if (item.idTercero == ItemListSelected.idTercero) { lsTemp.Add(ItemListSelected); } else { lsTemp.Add(item); } } LstEvidClients.Clear(); foreach (var item in lsTemp) { LstEvidClients.Add(item); } ClientSelected = null; return; } await Application.Current.MainPage.DisplayAlert("", "Debe seleccionar un cliente", "Ok"); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("TakePicture TakePicture", ex.Message, "Ok"); } }