internal static CompareListsService FromJObject(JObject jObject) { CompareListsService response = new CompareListsService(); response.id = jObject["id"].ToString (); response.nombre = jObject["name"].ToString(); response.imagen = jObject["photo"].ToString(); response.precio = jObject ["tot"].ToString (); response.count = jObject ["count"].ToString (); return response; }
internal static CompareListsService FromJObject(JObject jObject) { CompareListsService response = new CompareListsService(); response.id = jObject["id"].ToString(); response.nombre = jObject["name"].ToString(); response.imagen = jObject["photo"].ToString(); response.precio = jObject ["tot"].ToString(); response.count = jObject ["count"].ToString(); return(response); }
public List <CompareListsService> GetResponse() { WebClient client = new WebClient(); Stream stream = client.OpenRead(this.resultURL); StreamReader reader = new StreamReader(stream); JArray responseJSON = JArray.Parse(reader.ReadLine()); List <CompareListsService> responseList = new List <CompareListsService>(); foreach (JObject jobject in responseJSON) { CompareListsService response = CompareListsService.FromJObject(jobject); responseList.Add(response); } return(responseList); }
public override void ViewDidLoad () { base.ViewDidLoad (); try{ UIBarButtonItem home = new UIBarButtonItem(); home.Style = UIBarButtonItemStyle.Plain; home.Target = this; home.Image = UIImage.FromFile("Images/home.png"); this.NavigationItem.RightBarButtonItem = home; UIViewController[] vistas = NavigationController.ViewControllers; home.Clicked += (sender, e) => NavigationController.PopToViewController (vistas [0], true); ProductsInListView.tableView = this.tblProducts; //Configuramos la vista popup de cantidad amountView.Layer.BorderWidth = 1.0f; amountView.Layer.BorderColor = UIColor.Black.CGColor; amountView.Layer.CornerRadius = 8; //Configuramos la vista popup de comparacion de listas CompareView.Layer.BorderWidth = 1.0f; CompareView.Layer.BorderColor = UIColor.Black.CGColor; CompareView.Layer.CornerRadius = 8; tblProducts.Add (amountView); this.amountView.Hidden = true; tblProducts.Add (CompareView); this.CompareView.Hidden = true; pls.setListId (ProductsInListView.list_id); tableItems = pls.All (); this.productImages.Clear(); foreach (var v in tableItems){ Images image = new Images{ imageUrl = v.imagen}; this.productImages.Add(image); } if(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone){ tblProducts.TableHeaderView = this.FooterView; this.tblProducts.Source = new ProductsTableSourceIphone (tableItems, this); }else{ this.tblProducts.Source = new ProductsTableSource (tableItems, this); } Add (tblProducts); this.btnComparar.TouchUpInside += (sender, e) => { try{ if(tableItems.Count > 0){ compareListService = new CompareListsService(); compareListService.setListId(ProductsInListView.list_id); List<CompareListsService> tableItems2 = compareListService.All(); if(tableItems2.Count > 0){ storeImages.Clear(); foreach (var v in tableItems2){ Images image = new Images{ storeImageUrl = v.imagen}; this.storeImages.Add(image); } if(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone){ this.tblCompare.Source = new CompareTableSourceIphone(tableItems2,this); }else{ this.tblCompare.Source = new CompareTableSource(tableItems2,this); } tblCompare.TableHeaderView = this.headerView; CompareView.Add(tblCompare); this.tblCompare.ReloadData(); CompareView.Hidden = false; }else{ UIAlertView alerta = new UIAlertView () { Title = "Lo sentimos =(", Message = "Los productos de tu lista no se encuentran en su totalidad en ninguna de nuestras tiendas." }; alerta.AddButton ("Aceptar"); alerta.Show (); } }else{ UIAlertView alerta = new UIAlertView () { Title = "Espera!", Message = "No tienes productos en esta lista, agrega productos para que puedas comparar entre tiendas =)" }; alerta.AddButton ("Aceptar"); alerta.Show (); } }catch(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){ UIAlertView alerta = new UIAlertView () { Title = "Ups :S", Message = "Algo salio mal, por favor intentalo de nuevo." }; alerta.AddButton ("Aceptar"); alerta.Show (); } }; this.btnCompararUno.TouchUpInside += (sender, e) => { try{ if(tableItems.Count > 0){ compareListService = new CompareListsService(); compareListService.setUnoListId(ProductsInListView.list_id); List<CompareListsService> tableItems2 = compareListService.All(); if(tableItems2.Count > 0){ storeImages.Clear(); foreach (var v in tableItems2){ Images image = new Images{ storeImageUrl = v.imagen}; this.storeImages.Add(image); } if(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone){ this.tblCompare.Source = new CompareTableSourceIphone(tableItems2,this); }else{ this.tblCompare.Source = new CompareTableSource(tableItems2,this); } tblCompare.TableHeaderView = this.headerView; CompareView.Add(tblCompare); this.tblCompare.ReloadData(); CompareView.Hidden = false; }else{ UIAlertView alerta = new UIAlertView () { Title = "Lo sentimos =(", Message = "Los productos de tu lista no se encuentran en su totalidad en ninguna de nuestras tiendas." }; alerta.AddButton ("Aceptar"); alerta.Show (); } }else{ UIAlertView alerta = new UIAlertView () { Title = "Espera!", Message = "No tienes productos en esta lista, agrega productos para que puedas comparar entre tiendas =)" }; alerta.AddButton ("Aceptar"); alerta.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){ UIAlertView alerta = new UIAlertView () { Title = "Ups :S", Message = "Algo salio mal, por favor intentalo de nuevo." }; alerta.AddButton ("Aceptar"); alerta.Show (); } }; this.btnCerrar.TouchUpInside += (sender, e) => { CompareView.Hidden = true; }; this.btnScan.TouchUpInside += (sender, e) => { picker = new ScanditSDKRotatingBarcodePicker (MainView.appKey); picker.OverlayController.Delegate = new pickerControllerDelegate(picker, this); picker.OverlayController.ShowToolBar(true); picker.OverlayController.SetToolBarButtonCaption("Cancelar"); picker.OverlayController.SetCameraSwitchVisibility(SICameraSwitchVisibility.OnTablet); picker.OverlayController.SetTextForInitializingCamera("Iniciando la camara"); this.NavigationController.PushViewController(picker,true); picker.StartScanning (); }; this.btnAceptar.TouchUpInside += (sender, e) => { try{ AddProductFromBarcode apfb = new AddProductFromBarcode (); String respuesta = apfb.SetData ( ProductsInListView.barcode, ProductsInListView.list_id, cmpAmount.Text); Console.WriteLine (respuesta); if (respuesta.Equals ("\"El producto ya existe en esta lista\"")) { UIAlertView alert = new UIAlertView () { Title = "Ups :S", Message = "Este producto ya se encuentra registrado en tu lista" }; alert.AddButton ("Aceptar"); alert.Show (); } else if (respuesta.Equals ("\"El producto no existe\"")) { UIAlertView alert = new UIAlertView () { Title = "Ups :S", Message = "Este producto no esta registrado en fixbuy =(" }; alert.AddButton ("Aceptar"); alert.Show (); } else { UIAlertView alert = new UIAlertView () { Title = "Producto Agregado", Message = "El producto ha sido agregado a tu lista =D" }; alert.AddButton("Aceptar"); alert.Show (); pls.setListId (ProductsInListView.list_id); tableItems = pls.All (); if(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone){ this.tblProducts.Source = new ProductsTableSourceIphone (tableItems, this); }else{ this.tblProducts.Source = new ProductsTableSource (tableItems, this); } tblProducts.ReloadData (); this.amountView.Hidden = true; pickerControllerDelegate.scanned = false; } }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){ UIAlertView alerta = new UIAlertView () { Title = "Ups :S", Message = "Algo salio mal, por favor intentalo de nuevo." }; alerta.AddButton ("Aceptar"); alerta.Show (); } }; this.btnCancelar.TouchUpInside += (sender, e) => { this.amountView.Hidden = true; pickerControllerDelegate.scanned = false; }; int cantidad = 1; this.cmpAmount.Text = cantidad.ToString (); btnMas.TouchUpInside += (sender, e) => { cantidad ++; this.cmpAmount.Text = cantidad.ToString(); }; btnMenos.TouchUpInside += (sender, e) => { cantidad --; if(cantidad < 1){ UIAlertView alert = new UIAlertView () { Title = "Espera!", Message = "La cantidad minima es 1" }; alert.AddButton("Aceptar"); alert.Show(); cantidad = 1; this.cmpAmount.Text = cantidad.ToString(); }else{ this.cmpAmount.Text = cantidad.ToString(); } }; }catch(System.Net.WebException){ UIAlertView alert = new UIAlertView () { Title = "Ups =S", Message = "Algo salio mal, verifica tu conexión a internet e intentalo de nuevo." }; alert.AddButton("Aceptar"); alert.Show(); }catch(Exception ex){ Console.WriteLine (ex.ToString ()); UIAlertView alert = new UIAlertView () { Title = "Ups =S", Message = "Algo salio mal, por favor intentalo de nuevo." }; alert.AddButton("Aceptar"); alert.Show(); } }