public async void agregarPartida(object sender, EventArgs e) { ISharedPreferences preferences = PreferenceManager.GetDefaultSharedPreferences(this); string myValue = ""; PartidasModel partida = new PartidasModel(); partida.cantidad = Convert.ToInt32(txtcantidad.Text); partida.productoId = id.ToString(); if (preferences.GetBoolean("is_login", false)) { myValue = preferences.GetString("token", ""); } else { myValue = preferences.GetString("NotToken", ""); } partida.idCarrito = preferences.GetString("name", ""); partida.id = Guid.NewGuid().ToString(); partida.nombre = nombre; //partida.costo = 12; partida.pedidoId = "hola"; partida.costo = costo * Convert.ToInt32(txtcantidad.Text); string baseurl = "http://pushstart.azurewebsites.net/Carrito/agregar"; var Client = new HttpClient(); Client.MaxResponseContentBufferSize = 256000; var uri = new Uri(baseurl); var json = JsonConvert.SerializeObject(partida); StringContent content = new StringContent(json, Encoding.UTF8, "application/json"); var response = Client.PostAsync(uri, content).Result; if (response.IsSuccessStatusCode) { Toast.MakeText(this, "Exito", ToastLength.Short).Show(); } else { Toast.MakeText(this, "Ocurrio un error :c", ToastLength.Short).Show(); } Intent intento2 = new Intent(this, typeof(MenuActivity)); StartActivity(intento2); }
void quitar(object sender, EventArgs e) { //string dbPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "dbTienda.db3"); //db = new SQLitePedidoRepository(dbPath); //List<user> usuarios = db.Read(); ISharedPreferences preferences = PreferenceManager.GetDefaultSharedPreferences(this); string myValue = ""; PartidasModel partida = new PartidasModel(); partida.cantidad = cantidad; partida.productoId = idProducto; if (preferences.GetBoolean("is_login", false)) { myValue = preferences.GetString("token", ""); } else { myValue = preferences.GetString("NotToken", ""); } //partida.idCarrito = usuarios[0].tokenUsuario.ToString(); partida.idCarrito = myValue; partida.id = idPartida; partida.costo = precio * cantidad; partida.nombre = nombre; string baseurl = "http://pushstart.azurewebsites.net/Carrito/quitar"; var Client = new HttpClient(); Client.MaxResponseContentBufferSize = 256000; var uri = new Uri(baseurl); var json = JsonConvert.SerializeObject(partida); StringContent content = new StringContent(json, Encoding.UTF8, "application/json"); var response = Client.PutAsync(uri, content).Result; if (response.IsSuccessStatusCode) { Toast.MakeText(this, "Exito", ToastLength.Long).Show(); Intent intento = new Intent(this, typeof(carrito)); StartActivity(intento); } else { Toast.MakeText(this, "Ocurrio un error :c", ToastLength.Long).Show(); } }
void OnItemClick(object sender, int e) { PartidasModel a = partidasList[e]; ProductModel producto = ProductList[e]; var intento = new Intent(this, typeof(detalleProductoCompra)); Bundle contenedor = new Bundle(); contenedor.PutString("id", producto.Codigo); contenedor.PutString("nombre", producto.Nombre); contenedor.PutString("categoria", producto.Categoria); contenedor.PutString("precio", producto.Precio.ToString()); contenedor.PutString("descripcion", producto.Descripcion); contenedor.PutString("idPartida", a.id); contenedor.PutString("url", producto.url); //contenedor.PutString("idProducto", a.productoId); contenedor.PutInt("cantidad", a.cantidad); intento.PutExtra("bundle", contenedor); StartActivity(intento); }