internal static ProductSearchDetailService FromJObject(JObject jObject) { ProductSearchDetailService response = new ProductSearchDetailService(); response.id = jObject ["id"].ToString(); response.nombre = jObject["name"].ToString(); response.descripcion = jObject ["description"].ToString(); response.imagen = jObject["image_url"].ToString(); if (jObject ["price"].ToString() != "") { response.precio = jObject ["price"].ToString(); } else { response.precio = "0.00"; } response.tienda_id = jObject ["branch_id"].ToString(); response.tienda_nombre = jObject ["name_branch"].ToString(); response.tienda_direccion = jObject ["address"].ToString(); response.tienda_imagen = jObject ["branch_image_path"].ToString(); response.tienda_latitud = jObject ["latitude"].ToString(); response.tienda_longitud = jObject ["longitude"].ToString(); response.tienda_telefono = jObject ["phone"].ToString(); response.inicio_validez = jObject ["CAST(price_histories.validity_start as date)"].ToString(); response.final_validez = jObject ["CAST(price_histories.validity_end as date)"].ToString(); response.es_oferta = jObject ["price_type_id"].ToString(); return(response); }
internal static ProductSearchDetailService FromJObject(JObject jObject) { ProductSearchDetailService response = new ProductSearchDetailService(); response.id = jObject ["id"].ToString (); response.nombre = jObject["name"].ToString(); response.descripcion = jObject ["description"].ToString (); response.imagen = jObject["image_url"].ToString(); if (jObject ["price"].ToString () != "") { response.precio = jObject ["price"].ToString (); } else { response.precio = "0.00"; } response.tienda_id = jObject ["branch_id"].ToString (); response.tienda_nombre = jObject ["name_branch"].ToString (); response.tienda_direccion = jObject ["address"].ToString (); response.tienda_imagen = jObject ["branch_image_path"].ToString (); response.tienda_latitud = jObject ["latitude"].ToString (); response.tienda_longitud = jObject ["longitude"].ToString (); response.tienda_telefono = jObject ["phone"].ToString (); response.inicio_validez = jObject ["CAST(price_histories.validity_start as date)"].ToString (); response.final_validez = jObject ["CAST(price_histories.validity_end as date)"].ToString (); response.es_oferta = jObject ["price_type_id"].ToString (); return response; }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { UITableViewCell cell = tableView.DequeueReusableCell(cellIdentifier); ps = tableItems [indexPath.Row]; var image = controller.productImages [indexPath.Row]; // if there are no cells to reuse, create a new one if (cell == null) { cell = new MyCustomCell(UITableViewCellStyle.Value1, cellIdentifier); cell.TextLabel.Font = UIFont.SystemFontOfSize(15); cell.TextLabel.Lines = 2; cell.DetailTextLabel.Font = UIFont.SystemFontOfSize(20); cell.DetailTextLabel.TextColor = UIColor.Red; cell.DetailTextLabel.Lines = 2; cell.DetailTextLabel.TextAlignment = UITextAlignment.Left; } cell.AccessoryView = getDistanceView(indexPath.Row); cell.TextLabel.Text = ps.tienda_nombre; double precio = Double.Parse(ps.precio); cell.DetailTextLabel.Text = precio.ToString("C2") + " "; cell.Tag = indexPath.Row; if (image.storeImage == null) { image.storeImage = PlaceholderImage; BeginDownloadingImage(image, indexPath, ps.tienda_imagen); } cell.ImageView.Image = image.storeImage; return(cell); }
private ProductSearchDetailService GetProduct() { WebClient client = new WebClient(); Stream stream = client.OpenRead(this.resultURL); StreamReader reader = new StreamReader(stream); JObject jObject = JObject.Parse(reader.ReadLine()); ProductSearchDetailService product = ProductSearchDetailService.FromJObject(jObject); return(product); }
//Metodo de busqueda de la tienda mas cercana. public ProductSearchDetailService nearestStore(CLLocation location, List <ProductSearchDetailService> stores) { Console.WriteLine("" + location.Coordinate.Latitude); ProductSearchDetailService nearStore = stores.ElementAt(0); foreach (ProductSearchDetailService store in stores) { if ((location.DistanceFrom(new CLLocation(Double.Parse(store.tienda_latitud), Double.Parse(store.tienda_longitud)))) < (location.DistanceFrom(new CLLocation(Double.Parse(nearStore.tienda_latitud), Double.Parse(nearStore.tienda_longitud))))) { nearStore = store; } } return(nearStore); }
public List <ProductSearchDetailService> GetResponse() { WebClient client = new WebClient(); Stream stream = client.OpenRead(this.resultURL); StreamReader reader = new StreamReader(stream); JArray responseJSON = JArray.Parse(reader.ReadLine()); List <ProductSearchDetailService> responseList = new List <ProductSearchDetailService>(); foreach (JObject jobject in responseJSON) { ProductSearchDetailService response = ProductSearchDetailService.FromJObject(jobject); responseList.Add(response); } return(responseList); }
public AddToListsTableSource(List <ListsService> items, ProductDetailView controller, ProductSearchDetailService producto, int cantidad) { tableItems = items; this.producto = producto; this.cantidad = cantidad; }
public void setProductAndDistance(ProductSearchDetailService product, Double distance) { this.producto = product; this.distancia = distance; }
public AddToListsTableSource (List<ListsService> items, ProductDetailView controller, ProductSearchDetailService producto, int cantidad) { tableItems = items; this.producto = producto; this.cantidad = cantidad; }
public void setProductAndDistance(ProductSearchDetailService product, Double distance){ this.producto = product; this.distancia = distance; }
public void setTienda(ProductSearchDetailService tienda){ this.tienda = tienda; }
public override void ViewDidLoad() { base.ViewDidLoad(); try{ var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal); _pathToDatabase = Path.Combine(documents, "db_sqlite-net.db"); using (var db = new SQLite.SQLiteConnection(_pathToDatabase)) { people = new List <Person> (from p in db.Table <Person> () select p); } //inicializacion del manejador de localizacion. iPhoneLocationManager = new CLLocationManager(); //Establecer la precision del manejador de localizacion. iPhoneLocationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters; iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => { newLocation = e.Locations [e.Locations.Length - 1]; }; productSearchDetailService.setProductBarcode(this.barcode, MainView.localityId.ToString(), MainView.userId); List <ProductSearchDetailService> tableItems = productSearchDetailService.All(); this.productImages.Clear(); foreach (var v in tableItems) { Images image = new Images { storeImageUrl = v.imagen }; this.productImages.Add(image); } 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) => { this.NavigationController.PopToViewController(vistas[0], true); }; btnTiendaCercana.TouchUpInside += (sender, e) => { try{ ProductSearchDetailService tiendac = nearestStore(newLocation, tableItems); double distancia = newLocation.DistanceFrom(new CLLocation(Double.Parse(tiendac.tienda_latitud), Double.Parse(tiendac.tienda_longitud))) / 1000; distancia = Math.Round(distancia, 2); UIAlertView alert = new UIAlertView() { Title = "Tu tienda mas cercana es:", Message = "" + tiendac.tienda_nombre + "\n " + tiendac.tienda_direccion + "\n" + "Distancia: " + distancia.ToString() + "km" }; alert.AddButton("Aceptar"); alert.AddButton("Mapa"); alert.Clicked += (s, o) => { if (o.ButtonIndex == 1) { SecondMapViewController mapView = new SecondMapViewController(); mapView.setTienda(tiendac); this.NavigationController.PushViewController(mapView, true); } }; alert.Show(); }catch (NullReferenceException) { UIAlertView alert = new UIAlertView() { Title = "Lo Sentimos =(", Message = "FixBuy no pudo obtener tu ubicación por favor ve a Ajustes/Privacidad/Localizacion y verifica que Fixbuy tenga permiso de saber tu ubicación" }; alert.AddButton("Aceptar"); alert.Show(); } }; if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) { if (CLLocationManager.LocationServicesEnabled) { this.tblStores.Source = new StoresTableSourceIphone(tableItems, this, iPhoneLocationManager, people.Count); } else { this.tblStores.Source = new StoresTableSourceIphone(tableItems, this, null, people.Count); } } else { if (CLLocationManager.LocationServicesEnabled) { this.tblStores.Source = new StoresTableSource(tableItems, this, iPhoneLocationManager, people.Count); } else { this.tblStores.Source = new StoresTableSource(tableItems, this, null, people.Count); } } ProductSearchDetailService product = tableItems.ElementAt(0); NSUrl nsUrl = new NSUrl(product.imagen); NSData data = NSData.FromUrl(nsUrl); if (data != null) { this.imgProduct.Image = UIImage.LoadFromData(data); } else { this.imgProduct.Image = Images.sinImagen; } this.lblproduct.Text = product.nombre; this.lblDescription.Text = product.descripcion; //this.tblStores.TableHeaderView = this.headerView; Add(this.tblStores); // Manejamos la actualizacion de la localizacion del dispositivo. iPhoneLocationManager.RequestAlwaysAuthorization(); if (CLLocationManager.LocationServicesEnabled) { iPhoneLocationManager.StartUpdatingLocation(); } }catch (System.ArgumentOutOfRangeException) { didNotFidProduct(); }catch (Exception ex) { Console.WriteLine("ESTA ES LA EXCEPCION: " + ex.ToString()); this.imgProduct.Image = UIImage.FromFile("Images/noImage.jpg"); this.lblproduct.Text = "Producto no encontrado =S"; this.lblDescription.Text = ""; this.btnTiendaCercana.Hidden = true; this.tblStores.BackgroundColor = UIColor.Clear; UIAlertView alert = new UIAlertView() { Title = "Ups =(", Message = "Lo sentimos algo salio mal, por favor intentalo de nuevo" }; alert.AddButton("Aceptar"); alert.Show(); } }
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) { UITableViewCell cell = tableView.DequeueReusableCell (cellIdentifier); ps = tableItems [indexPath.Row]; var image = controller.productImages [indexPath.Row]; // if there are no cells to reuse, create a new one if (cell == null) { cell = new MyCustomCell (UITableViewCellStyle.Value1, cellIdentifier); cell.TextLabel.Font = UIFont.SystemFontOfSize (15); cell.TextLabel.Lines = 2; cell.DetailTextLabel.Font = UIFont.SystemFontOfSize (20); cell.DetailTextLabel.TextColor = UIColor.Red; cell.DetailTextLabel.Lines = 2; cell.DetailTextLabel.TextAlignment = UITextAlignment.Left; } cell.AccessoryView = getDistanceView (indexPath.Row); cell.TextLabel.Text = ps.tienda_nombre; double precio = Double.Parse (ps.precio); cell.DetailTextLabel.Text = precio.ToString ("C2") + " "; cell.Tag = indexPath.Row; if (image.storeImage == null) { image.storeImage = PlaceholderImage; BeginDownloadingImage (image, indexPath, ps.tienda_imagen); } cell.ImageView.Image = image.storeImage; return cell; }
public void setTienda(ProductSearchDetailService tienda) { this.tienda = tienda; }