private async void TxtConceptoTipoRecordatorioId_OnClicked(object sender, EventArgs e) { var prest = new SolicitarPrestamoInput { ConceptoTipoRecordatorioId = Prestamo.ConceptoTipoRecordatorioId, ClienteId = Prestamo.ClienteId, Comentario = TxtComentario.Text }; //var frecuencia = GetFrecuencias().Single(n => n.Key == ); //if (frecuencia != null) if (PickerFrecuencia.SelectedIndex > -1) { prest.Frecuencia = GetFrecuencias().Single(n => n.Nombre == PickerFrecuencia.Items[PickerFrecuencia.SelectedIndex]).Key; } if (PickerTipoInteresId.SelectedIndex > -1) { prest.TipoInteresId = int.Parse(GettipoInteres().Single(n => n.Nombre == PickerTipoInteresId.Items[PickerTipoInteresId.SelectedIndex]).Key); } if (TxtMonto.Text != null) { prest.Monto = decimal.Parse(TxtMonto.Text); } if (TxtTasa.Text != null) { prest.Tasa = decimal.Parse(TxtTasa.Text); } //SetearPrestamo(prest); await Navigation.PushAsync(new ConceptoTipoRecordatorioPage(prest, Nombre, Apellido)); }
private void SetearPrestamo(SolicitarPrestamoInput input) { Prestamo = input; if (Prestamo.Monto > 0) { TxtMonto.Text = Prestamo.Monto.ToString(CultureInfo.InvariantCulture); } TxtComentario.Text = Prestamo.Comentario; if (Prestamo.Frecuencia != null) { PickerFrecuencia.SelectedItem = GetFrecuencias().Single(n => n.Key == Prestamo.Frecuencia).Nombre; } if (Prestamo.TipoInteresId > 0) { PickerTipoInteresId.SelectedItem = GettipoInteres().Single(n => int.Parse(n.Key) == Prestamo.TipoInteresId).Nombre; } if (Prestamo.Tasa > 0) { TxtTasa.Text = Prestamo.Tasa.ToString(CultureInfo.InvariantCulture); } if (input.ConceptoTipoRecordatorioId.Count > 0) { ConceptoTipoRecordatorioIdButton.Text = string.Join(",", input.ConceptoTipoRecordatorioId); } }
private async void SolicitarPrestamoClicked(object sender, EventArgs e) { var solicitarPrestamo = new SolicitarPrestamoInput { ClienteId = CxcItem.ClienteId, ConceptoTipoRecordatorioId = (from rc in CxcItem.RecordatorioCliente select rc.ConceptoTipoRecordatorioId).ToList() }; await Navigation.PushAsync(new SolicitarPrestamoContentPage(solicitarPrestamo, CxcItem.Nombre, CxcItem.Apellido)); }
public ConceptoTipoRecordatorioPage(SolicitarPrestamoInput prestamo, string nombre, string apellido) { InitializeComponent(); PopulateCeckbox(prestamo.ConceptoTipoRecordatorioId); Nombre = nombre; Apellido = apellido; Prestamo = prestamo; }
public SolicitarPrestamoContentPage(SolicitarPrestamoInput input, string nombre, string apellido) { InitializeComponent(); Nombre = nombre; Apellido = apellido; foreach (var tipoInteres in GettipoInteres()) { PickerTipoInteresId.Items.Add(tipoInteres.Nombre); } foreach (var frecuencia in GetFrecuencias()) { PickerFrecuencia.Items.Add(frecuencia.Nombre); } AuthenticationService = DependencyService.Get <IAuthenticationService>(); Title = nombre + " " + apellido; SetearPrestamo(input); }
private async void BtnCrearCliente_OnClicked(object sender, EventArgs e) { try { var confimacion = await DisplayAlert(null, "Esta seguro que desea registrar el cliente", "SI", "NO"); if (confimacion == false) { return; } var userContext = await AuthenticationService.SignInAsync(); var token = userContext.AccessToken; // Get data from API var client = new HttpClient(); var message = new HttpRequestMessage(HttpMethod.Post, _guardarCliente); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); var tipoIdentificacion = PickerTipoIdentificacion.SelectedIndex == 0 ? 1 : 2; var mensaje = new GuardarClienteInput { TipoIdentificacion = tipoIdentificacion, Telefono = TxtTelefono.Text, Nombre = TxtNombre.Text, Apellido = TxtApellido.Text, CorreoElectronico = TxtCorreoElectronico.Text, Identificacion = TxtIdentificacion.Text }; var json = JsonConvert.SerializeObject(mensaje); HttpContent content = new StringContent(json); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var response = await client.PostAsync(_guardarCliente, content); var responseString = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.Created) { var deseaPrestamo = await DisplayAlert("Exito!", "Cliente registrado satisfactoriamente, desea registrar un prestamo para este cliente", "SI", "NO"); var clienteId = int.Parse(responseString); //Actualizo el cache //SolicitarPrestamoInput var prestamo = new SolicitarPrestamoInput { ClienteId = clienteId }; if (deseaPrestamo) { await Navigation.PushAsync(new SolicitarPrestamoContentPage(prestamo, TxtNombre.Text, TxtApellido.Text)); } else { await Navigation.PushAsync(new CuentasPorCobrar()); } } else if (response.StatusCode == HttpStatusCode.Conflict) { await DisplayAlert("Conflicto", responseString, "OK", "Cancel"); } } catch (Exception exception) { Console.WriteLine(exception); throw; } }
private async void BtnSolicitarPrestamo_OnClicked(object sender, EventArgs e) { try { var confimacion = await DisplayAlert(null, "Esta seguro que desea registrar el prestamo", "SI", "NO"); if (confimacion == false) { return; } var userContext = await AuthenticationService.SignInAsync(); var token = userContext.AccessToken; // Get data from API var client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); var frecuencia = GetFrecuencias().Single(n => n.Nombre == PickerFrecuencia.Items[PickerFrecuencia.SelectedIndex]); var tipoInteres = GettipoInteres().Single(n => n.Nombre == PickerTipoInteresId.Items[PickerTipoInteresId.SelectedIndex]); var mensaje = new SolicitarPrestamoInput { ClienteId = Prestamo.ClienteId, ConceptoTipoRecordatorioId = Prestamo.ConceptoTipoRecordatorioId, TipoInteresId = int.Parse(tipoInteres.Key), Frecuencia = frecuencia.Key, Monto = decimal.Parse(TxtMonto.Text), Comentario = TxtComentario.Text, Tasa = (decimal.Parse(TxtTasa.Text) / 100) }; var json = JsonConvert.SerializeObject(mensaje); HttpContent content = new StringContent(json); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var response = await client.PostAsync(_solicitarPrestamo, content); var responseString = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.Created) { await DisplayAlert("Exito!", "Prestamo registrado satisfactoriamente", "OK"); //aqui actualizar la cache Barrel.Current.EmptyAll(); //var prestamoId = int.Parse(responseString); //Actualizo el cache //SolicitarPrestamoInput await Navigation.PushAsync(new CuentasPorCobrar()); } else if (response.StatusCode == HttpStatusCode.Conflict) { await DisplayAlert("Conflicto", responseString, "OK", "Cancel"); } } catch (Exception exception) { Console.WriteLine(exception); throw; } }