public async Task <bool> Recargar(customer_info customer) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://smsteleyuma.azurewebsites.net/Service1.svc/TransferTo/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var param = new topupInfo() { msisdn = customer.phone1, destination_msisdn = this.numero, product = this.monto.ToString(), sender_sms = "yes", action = "topup" }; var response = await client.PostAsync("topup", param.AsJsonStringContent()); var Result = await response.Content.ReadAsStringAsync(); try { this.topupResponse = JsonConvert.DeserializeObject <topupResponse>(Result); return(true); } catch { return(false); } } }
public async Task <nautaResponse> Simular(customer_info customer) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://smsteleyuma.azurewebsites.net/Service1.svc/TransferTo/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var nauta = new nautaInfo { account_number = this.account_number, product_id = this.product_id, monto = this.monto, simulation = "1", recipient_sms_notification = "1", sender_sms_notification = true, sender = new nautaUser { last_name = customer.lastname, middle_name = "", first_name = customer.firstname, email = customer.email, mobile = Convert.ToInt64(customer.phone1) }, recipient = new nautaUser { last_name = "", middle_name = "", first_name = "", email = this.account_number, mobile = 99999999 } }; try { var response = await client.PostAsync("nauta", nauta.AsJsonStringContent()); var Result = await response.Content.ReadAsStringAsync(); var nautaResponse = JsonConvert.DeserializeObject <nautaResponse>(Result); return(nautaResponse); } catch (Exception) { var nautaResponse = new nautaResponse(); nautaResponse.erroe_code = "-1"; nautaResponse.error_message = "Error de conección"; return(nautaResponse); } } }
public async Task <List <customer_info> > GetAccountList(customer_info CurrentCustomer) { using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); try { var param = new GetCustomerListRequest { offset = 0, limit = 10000 }.AsJson(); var URL = _Global.BaseUrlAdmin + _Global.Servicio.Customer + "/" + _Global.Metodo.get_customer_list + "/" + await _Global.GetAuthInfoAdminJson() + "/" + param; var response = await client.GetAsync(URL); var json = await response.Content.ReadAsStringAsync(); var ErrorHandling = JsonConvert.DeserializeObject <ErrorHandling>(json); if (ErrorHandling.faultstring is null) { var result = JsonConvert.DeserializeObject <GetCustomerListResponse>(json).customer_list; return(result.Where(x => x.i_distributor == CurrentCustomer.i_customer).ToList()); } else { return(new List <customer_info>()); } } catch (Exception ex) { return(new List <customer_info>()); } } }
public async Task Cargar(customer_info CurrentCustomer) { var montoDepositar = new MontoDepositar(); var resumenRecargas = new ResumenRecargas(); float SuMonto = 0; float MontoAsociados = 0; float MontoComisiones = 0; //Detalle de comisiones var ArrayCustomerXDRInfo = new List <List <CustomerXDRInfo> >(); var xdrs = this.XDRListResponse.xdr_list.ToList(); //var xdrs = XDRS; foreach (var item in xdrs) { var list = new List <CustomerXDRInfo>(); var sihay = false; if (item.XdrIsAccount()) { foreach (var listaCustomerXDRInfo in ArrayCustomerXDRInfo) { if (listaCustomerXDRInfo.Any()) { if (listaCustomerXDRInfo.First().XdrIdAsociado() == item.XdrIdAsociado()) { listaCustomerXDRInfo.Add(item); sihay = true; } } } if (!sihay) { list.Add(item); ArrayCustomerXDRInfo.Add(list); } } //Recargas Moviles if (item.XdrIsMovil()) { //Monto a depositar if (item.XdrIsAccount()) { montoDepositar.SusAsociadosCantidad += 1; montoDepositar.SusAsociados += item.charged_amount; montoDepositar.Comisiones += item.XdrGetCustomerComision((float)CurrentCustomer.GetComisionTopUp()); } else if (item.XdrIsCustomer()) { montoDepositar.PorUstedCantiad += 1; montoDepositar.PorUsted += item.charged_amount; } //Resumen Recargas resumenRecargas.RecargasMoviles += 1; resumenRecargas.MontoRecargasMoviles += item.charged_amount; } //Recargas Nautas if (item.XdrIsNauta()) { if (item.XdrIsAccount()) { montoDepositar.SusAsociadosCantidad += 1; montoDepositar.SusAsociados += item.charged_amount; montoDepositar.Comisiones += item.XdrGetCustomerComision((float)CurrentCustomer.GetComisionTopUp()); } else //Monto a depositar if (item.XdrIsCustomer()) { montoDepositar.PorUstedCantiad += 1; montoDepositar.PorUsted += item.charged_amount; } resumenRecargas.RecargasNautas += 1; resumenRecargas.MontoRecargasNautas += item.charged_amount; } } this.MontoDepositar = montoDepositar; this.ResumenRecargas = resumenRecargas; ; var detalleComisiones = new List <DetalleComisiones>(); foreach (var items in ArrayCustomerXDRInfo) { var detalleComis = new DetalleComisiones(); var accountInfo = await CurrentCustomer.GetAccountById(items.First().XdrIdAsociado().ToString()); if (accountInfo == null) { detalleComis.IdCuenta = items.First().XdrIdAsociado().ToString(); detalleComis.Nombre = "Cuenta Eliminada"; } else { detalleComis.IdCuenta = accountInfo.i_customer.ToString(); detalleComis.Nombre = accountInfo.fullname; } foreach (var xdr in items) { detalleComis.Monto += xdr.charged_amount; detalleComis.Comision += xdr.XdrGetCustomerComision((float)CurrentCustomer.GetComisionTopUp()); } detalleComisiones.Add(detalleComis); CultureInfo culture = new CultureInfo("en-US"); DateTime tempDate = Convert.ToDateTime("1/1/2010 12:10:15 PM", culture); } this.DetalleComisiones = detalleComisiones; }