Пример #1
0
        private ProductsInListService GetProduct()
        {
            WebClient             client  = new WebClient();
            Stream                stream  = client.OpenRead(this.resultURL);
            StreamReader          reader  = new StreamReader(stream);
            JObject               jObject = JObject.Parse(reader.ReadLine());
            ProductsInListService product = ProductsInListService.FromJObject(jObject);

            return(product);
        }
		internal static ProductsInListService FromJObject(JObject jObject)
		{
			ProductsInListService response = new ProductsInListService();
			response.id = jObject ["id"].ToString ();
			response.nombre = jObject["name"].ToString();
			response.descripcion = jObject ["description"].ToString ();
			response.imagen = jObject["image_url"].ToString();
			response.list_id = jObject ["list_id"].ToString ();
			response.codigo = jObject ["bar_code"].ToString ();
			response.cantidad = jObject ["product_amount"].ToString ();

			return response;
		}
Пример #3
0
        internal static ProductsInListService FromJObject(JObject jObject)
        {
            ProductsInListService response = new ProductsInListService();

            response.id          = jObject ["id"].ToString();
            response.nombre      = jObject["name"].ToString();
            response.descripcion = jObject ["description"].ToString();
            response.imagen      = jObject["image_url"].ToString();
            response.list_id     = jObject ["list_id"].ToString();
            response.codigo      = jObject ["bar_code"].ToString();
            response.cantidad    = jObject ["product_amount"].ToString();

            return(response);
        }
Пример #4
0
        public List <ProductsInListService> GetResponse()
        {
            WebClient    client       = new WebClient();
            Stream       stream       = client.OpenRead(this.resultURL);
            StreamReader reader       = new StreamReader(stream);
            JArray       responseJSON = JArray.Parse(reader.ReadLine());
            List <ProductsInListService> responseList = new List <ProductsInListService>();

            foreach (JObject jobject in responseJSON)
            {
                ProductsInListService response = ProductsInListService.FromJObject(jobject);

                responseList.Add(response);
            }

            return(responseList);
        }
Пример #5
0
			public void buttonEvent(CGPoint buttonPosition){
				NSIndexPath indexPath = controller.tblProducts.IndexPathForRowAtPoint (buttonPosition);
				UIAlertView alert = new UIAlertView () { 
					Title = "Borrar?", Message = "Deseas borrar este producto?"
				};
				alert.AddButton ("Aceptar");
				alert.AddButton ("Cancelar");
				alert.Clicked += (s, o) => {
					try{
						if(o.ButtonIndex == 0){
							DestroyService destroyService = new DestroyService ();
							String respuesta = destroyService.destroyProductInList(tableItems[indexPath.Row].id,tableItems[indexPath.Row].list_id);
							if (respuesta.Equals ("\"correct\"")) {
								UIAlertView alert1 = new UIAlertView () { 
									Title = "Producto borrado", Message = "El producto ha sido borrado =)"
								};
								alert1.AddButton("Aceptar");
								alert1.Show ();
								ProductsInListService ls = new ProductsInListService();
								ls.setListId(ProductsInListView.list_id);
								List<ProductsInListService> productos = ls.All();
								ProductsInListView.tableView.Source = new ProductsTableSourceIphone(productos,this.controller);
								controller.productImages.Clear();
								foreach (var v in this.tableItems){
									Images image = new Images{ imageUrl = v.imagen};
									controller.productImages.Add(image);
								}
								ProductsInListView.tableView.ReloadData ();
							}else if(respuesta.Equals("\"error\"")){
								UIAlertView alert2 = new UIAlertView () { 
									Title = "Ups :S", Message = "Algo salio mal, por favor intentalo de nuevo"
								};
								alert2.AddButton("Aceptar");
								alert2.Show ();
							}
						}
					}catch(System.Net.WebException){
						UIAlertView alerta = new UIAlertView () { 
							Title = "Ups =S", Message = "Algo salio mal, verifica tu conexión a internet e intentalo de nuevo."
						};
						alerta.AddButton("Aceptar");
						alerta.Show();
					}catch(Exception ex){
						Console.WriteLine(ex.ToString());
						UIAlertView alerta = new UIAlertView () { 
							Title = "Ups =S", Message = "Algo salio mal, por favor intentalo de nuevo."
						};
						alerta.AddButton("Aceptar");
						alerta.Show();
					}
				};
				alert.Show ();
			}