public async void Instance() { try { apiService = new ApiServices(); this.Imagen = "ic_nodispon"; this.IdIdentifica = 0; this.NameClient = string.Empty; this.imgByte = null; this.Descripcion = string.Empty; this.Identification = string.Empty; this.withData = false; this.WithClientSelected = false; this.newClient = false; this.SiglaTypeDoc = string.Empty; this.file = null; SearchServices searchService = new SearchServices(); ItemListSelected = new EvidenciasModel(); LstEvidClients = null; LstEvidClients = new ObservableCollection <EvidenciasModel>(); Evidences = new EvidenciasModel(); EvidenceSave = new ObservableCollection <EvidenciasModel>(); ClientSelected = new EvidenciasModel(); TypesDoc = await searchService.GetTypeDoc(); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("TakePicture Instance", ex.ToString(), "Ok"); } }
private async void Instance() { try { this.apiService = new ApiServices(); this.NewClient = new ClientesModel(); this.IdIdentifica = 0; this.Identification = string.Empty; this.FirstName = string.Empty; this.SecondName = string.Empty; this.FirstLastName = string.Empty; this.SecondLastName = string.Empty; this.NameClient = string.Empty; this.Gustos = string.Empty; this.withData = false; this.DataNewClient = false; this.IdTypeDoc = 0; SearchServices searchService = new SearchServices(); Evidences = new EvidenciasModel(); ClientSave = new ClientesModel(); TypesDoc = await searchService.GetTypeDoc(); TypeDocSelected = TypesDoc.FirstOrDefault(x => x.id == IdTypeDoc); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("AddClient Instance", ex.ToString(), "Ok"); } }
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 CallSearchData() { 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; this.IdIdentifica = Evidences.idTercero; if (Evidences.idTercero == 0) { this.DataNewClient = true; this.withData = false; } else { withData = true; isProcessing = false; } } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("TakePicture SearchData", ex.Message, "Ok"); } }
public async Task <EvidenciasModel> SearchData(EvidenciasModel SearchEvidences) { EvidenciasModel EvidenceData = new EvidenciasModel(); try { var apiRoom = Application.Current.Resources["APISecurity"].ToString(); var response = await this.apiService.GetList <EvidenciasModel>(apiRoom, "api/GetClients?identification=" + SearchEvidences.identifClient + "&idTypeDoc=" + SearchEvidences.typeDoc, ""); if (!response.IsSuccess) { await Application.Current.MainPage.DisplayAlert( "Error A-Clients", response.Message, "Ok"); return(EvidenceData); } List <EvidenciasModel> lsTemp = (List <EvidenciasModel>)response.Result; foreach (var item in (List <EvidenciasModel>)response.Result) { EvidenceData.identifClient = item.identifClient; EvidenceData.idTercero = item.idTercero; EvidenceData.firstName = item.firstName; EvidenceData.secondName = item.secondName; EvidenceData.firstLastName = item.firstLastName; EvidenceData.secondLastName = item.secondLastName; EvidenceData.nameClient = item.nameClient; } if (lsTemp.Count == 0) { EvidenceData.nameClient = "No se encuentra ningun cliente con los datos ingresados."; } } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("TakePicture SearchData", ex.Message, "Ok"); } return(EvidenceData); }
private async void AddClient() { try { if (isProcessing) { return; } isProcessing = true; bool ask = false; EvidenciasModel objLstEvidClients = new EvidenciasModel(); if (string.IsNullOrEmpty(this.FirstName) && !this.withData) { await Application.Current.MainPage.DisplayAlert("", "Ingrese Primer Nombre", "Ok"); isProcessing = false; return; } if (string.IsNullOrEmpty(this.FirstLastName) && !this.withData) { await Application.Current.MainPage.DisplayAlert("", "Ingrese Primer Apellido", "Ok"); isProcessing = false; return; } countList = MainViewModel.GetInstance().Documentation.LstEvidClients.Count(); objLstEvidClients.nameClient = this.NameClient; objLstEvidClients.identifClient = this.Identification; objLstEvidClients.idTercero = this.IdIdentifica; objLstEvidClients.sigla = this.TypeDocSelected.nameAux; objLstEvidClients.holder = countList == 0 ? true : false; if (Evidences.idTercero == 0) { var resultado = await Application.Current.MainPage.DisplayAlert("Crear Cliente", "¿Desea crear cliente : " + this.FirstName + " " + this.FirstLastName + " ?", "Si", "No"); if (resultado) { ClientSave.TypeDoc = this.TypeDocSelected.id; ClientSave.Id = this.Identification; ClientSave.FirstName = this.FirstName; ClientSave.SecondName = this.SecondName == null ? "" : this.SecondName; ClientSave.FirstLastName = this.FirstLastName; ClientSave.SecondLastName = this.SecondLastName == null ? "" : this.SecondLastName; ClientSave.NameComplete = this.FirstName + " " + this.SecondName + " " + this.FirstLastName + " " + this.SecondLastName; ClientSave.Gustos = this.Gustos; ClientSave.fec_Graba = DateTime.Now; ClientSave.Usuario = MainViewModel.GetInstance().Login.User; var apiS = Application.Current.Resources["APISecurity"].ToString(); var response = await this.apiService.PostBool( apiS, "/api", "/PostNewClient", ClientSave); if (!response.IsSuccess) { await Application.Current.MainPage.DisplayAlert( "Error AP-Client", response.Message, "Ok"); isProcessing = false; return; } ask = true; this.IdIdentifica = Convert.ToInt32(response.Result); this.NameClient = ClientSave.NameComplete; objLstEvidClients.idTercero = this.IdIdentifica; objLstEvidClients.nameClient = this.NameClient; } } EvidenciasModel evidenciasAdd = MainViewModel.GetInstance().Documentation.LstEvidClients.FirstOrDefault(x => x.idTercero == this.IdIdentifica); if (evidenciasAdd == null) { var resultado2 = ask ? true : await Application.Current.MainPage.DisplayAlert("Agregar Cliente", "¿Desea agregar cliente : " + this.NameClient + " ?", "Si", "No"); if (resultado2) { if (objLstEvidClients.holder) { MainViewModel.GetInstance().Documentation.NameClient = this.NameClient; MainViewModel.GetInstance().Documentation.Identification = this.Identification; MainViewModel.GetInstance().Documentation.TypeDocSelected = MainViewModel.GetInstance().Documentation.TypesDoc.FirstOrDefault(x => x.id == TypeDocSelected.id); } MainViewModel.GetInstance().Documentation.LstEvidClients.Add(objLstEvidClients); await Application.Current.MainPage.DisplayAlert("Agregado", "Agregado correctamente", "Ok"); Instance(); await Application.Current.MainPage.Navigation.PopModalAsync(); } isProcessing = false; return; } await Application.Current.MainPage.DisplayAlert("", "El cliente " + this.NameClient + " ya se encuentra en la lista", "Ok"); Instance(); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("AddClient AddClient", ex.ToString(), "Ok"); } isProcessing = false; }