public List <CouponSchedule> GetCoupons(List <CouponSchedule> couponSched = null) { // List<String> place = new List<String>(); List <Coupon> coupons = new List <Coupon>(); List <CouponSchedule> retList = new List <CouponSchedule>(); CouponSchedule retC; //Coupon coupon; String placeStr = ""; int i = 0; if (couponSched.Count > 0) { foreach (var p in couponSched) { placeStr = placeStr + "'" + p.CouponId + "', "; i++; } placeStr = placeStr.Substring(0, placeStr.Length - 2); //coupon = new Coupon(); //SELECT c.Id, c.CouponId FROM Coupons c LEFT JOIN StoreLocations sl ON sl.StoreId = c.Id WHERE sl.PlaceId = '' var query = "SELECT Id, CouponId FROM Coupons WHERE Id IN (" + placeStr + ")"; coupons = (List <Coupon>)AzureConnect(query, "CouponList"); } foreach (var cs in couponSched) { retC = new CouponSchedule(); retC.thisCoupon = new Coupon(); if (!(coupons.Count > 0)) { var checkNull = coupons.Where(c => c.id == cs.CouponId).FirstOrDefault(); if (checkNull != null) { retC.thisCoupon = checkNull; retC.notInSystem = false; } else { retC.notInSystem = true; } } else { retC.notInSystem = true; } retC.thisCoupon.GoogleData = cs.thisCoupon.GoogleData; retList.Add(retC); } return(retList); }
public void AddToBackpack(CouponSchedule _coupon, User _user) { cmd.CommandText = "INSERT INTO UserBackpack (UserId, CouponId) VALUES ('" + _user.Id + "', '" + _coupon.thisCoupon.id + "')"; cmd.CommandType = CommandType.Text; cmd.Connection = connection; connection.Open(); int newrows = cmd.ExecuteNonQuery(); Console.WriteLine($"Inserted {newrows} row(s)."); connection.Close(); }
public FindPlacePage(CouponSchedule couponInfo, Plugin.Geolocator.Abstractions.Position pos) { InitializeComponent(); double Lat = pos.Latitude; double Long = pos.Longitude; var googleInfo = couponInfo.thisCoupon.GoogleData; // double myLat = _myLocation.lat; // double myLong = _myLocation.lng; // locator = CrossGeolocator.Current.; StackLayout mainStack = new StackLayout() { Margin = 10 }; StackLayout infoStack = new StackLayout() { Orientation = StackOrientation.Horizontal, MinimumHeightRequest = 300 }; Label phoneNumber = new Label() { Text = googleInfo.phone_number }; Label openNow = new Label() { Text = googleInfo.opening_hours.open_now.ToString() }; infoStack.Children.Add(phoneNumber); infoStack.Children.Add(openNow); // List<Label> openHours = new List<Label>() { } var position = new Position(googleInfo.geometry.location.lat, googleInfo.geometry.location.lng); // Latitude, Longitude var pin = new Pin { Type = PinType.Place, Position = position, Label = couponInfo.thisCoupon.GoogleData.name, Address = couponInfo.thisCoupon.GoogleData.address }; _map.Pins.Add(pin); _map.IsShowingUser = true; _map.InitialCameraUpdate = CameraUpdateFactory.NewCameraPosition(new CameraPosition( new Position(Lat, Long), // latlng 14d, // zoom 30d, // rotation 60d)); mainStack.Children.Add(_map); mainStack.Children.Add(infoStack); // mainStack.Children.Add(); Content = mainStack; }
// private async Task<List<CouponSchedule>> getGoogleInfo(Location loc) // { // List<CouponSchedule> cpns = new List<CouponSchedule>(); // int j = 0; // // string oneRestUrl = setLocation(loc); // using (var client = new HttpClient()) // { // // var response = await client.GetStringAsync(string.Format(oneRestUrl)); // var result = JsonConvert.DeserializeObject<GooglePlaces>(response); // foreach (var info in result.results) // { // CouponSchedule cpn = new CouponSchedule(); // cpn.thisCoupon = new Coupon(); // Console.WriteLine("pat look here =="+info.name); // cpn.thisCoupon.GoogleData = info; // cpns.Add(cpn); // j++; // } // } // return cpns; //} async void FindThisPlace(object sender, FindEventArgs e) { Console.WriteLine("in Group Details - AddNewMEssages"); //BindingContext = _currentChatGroup; //_currentChatGroup.ToDoList = schdmsg.provideDates(); CouponSchedule lookingFor = e.Data; lookingFor = await _google.GooglePlaceDetails(lookingFor); FindPlacePage findPlace = new FindPlacePage(lookingFor, position); await Navigation.PushAsync(findPlace); // toDo.AddToList(addmsg.returnMessages()); //toDo.RefreshItems(true); }
public async Task <CouponSchedule> GooglePlaceDetails(CouponSchedule _coupon) { var searchString = detailSearch + _coupon.thisCoupon.GoogleData.place_id + googleKey; using (var client = new HttpClient()) { var response = await client.GetStringAsync(string.Format(searchString)); var result = JsonConvert.DeserializeObject <GooglePlaces>(response); if (result.result != null) { var use = result.result; _coupon.thisCoupon.GoogleData = use; // Console.WriteLine("use=>" + use.place_id); } } return(_coupon); }
public async Task <List <CouponSchedule> > GoogleNearby(Location myLoc) { List <CouponSchedule> cpns = new List <CouponSchedule>(); string nextPage = ""; int i = 0; int o = 0; for (int b = 0; b < 2; b++) { using (var client = new HttpClient()) { var searchString = nearbySearch + myLoc.lat + "," + myLoc.lng + defaultRange + googleKey + "&pagetoken=" + nextPage; Console.WriteLine(searchString); var response = await client.GetStringAsync(string.Format(searchString)); var result = JsonConvert.DeserializeObject <GooglePlaces>(response); nextPage = result.next_page_token; foreach (var info in result.results) { CouponSchedule cpn = new CouponSchedule(); cpn.thisCoupon = new Coupon(); cpn.thisCoupon.GoogleData = info; cpns.Add(cpn); } int milliseconds = 250; Thread.Sleep(milliseconds); } } foreach (var c in cpns) { Console.WriteLine(o + "checking this ==" + c.thisCoupon.GoogleData.name); o++; } return(cpns); }
public FindEventArgs(CouponSchedule data) { m_Data = data; }
public async Task <ObservableCollection <CouponSchedule> > GetTodoItemsAsync(List <CouponSchedule> couponList, bool syncItems = false) { try { #if OFFLINE_SYNC_ENABLED if (syncItems) { await this.SyncAsync(); } #endif List <string> placeList = new List <string>(); foreach (var cl in couponList) { placeList.Add(cl.thisCoupon.GoogleData.place_id); Console.WriteLine("before====>" + cl.thisCoupon.GoogleData.name); } IEnumerable <CouponSchedule> items = await couponTable //.Take(50) // .ToListAsync(); // .Where(cpnItem => _couponSchedule.Contains(cpnItem.PlaceId)) .Where(ct => placeList.Contains(ct.PlaceId)) // .OrderBy(time => time.SendTime) .ToEnumerableAsync(); int b = 0; List <CouponSchedule> fixList = new List <CouponSchedule>(); CouponSchedule addCoupon; foreach (var cl in couponList) { addCoupon = new CouponSchedule(); var place = cl.thisCoupon.GoogleData.place_id; if (items.Where(i => i.PlaceId == place).FirstOrDefault() != null) { Console.WriteLine("THIS PLACE ID IS IN OUR SERVER! => " + place); addCoupon = items.Where(i => i.PlaceId == place).FirstOrDefault(); addCoupon.thisCoupon = new Coupon(); addCoupon.thisCoupon.GoogleData = cl.thisCoupon.GoogleData; addCoupon.notInSystem = false; } else { Console.WriteLine("XXXXXXXXXXXXXXXXXX NOT IN OUR SERVER! => " + place); addCoupon = cl; Console.WriteLine(cl.thisCoupon.GoogleData.name); addCoupon.notInSystem = true; } fixList.Add(addCoupon); } //foreach (var i in items) //{ // addCoupon = i; // addCoupon.Loc.lat = couponList.Where(cl => cl.PlaceId == i.PlaceId).Select(l => l.Loc.lat).FirstOrDefault(); // addCoupon.Loc.lng = couponList.Where(cl => cl.PlaceId == i.PlaceId).Select(l => l.Loc.lng).FirstOrDefault(); // fixList.Add(addCoupon); //} return(new ObservableCollection <CouponSchedule>(fixList)); } catch (MobileServiceInvalidOperationException msioe) { Debug.WriteLine(@"Invalid sync operation: {0}", msioe.Message); } catch (Exception e) { Debug.WriteLine(@"Sync error: {0}", e.Message); } return(new ObservableCollection <CouponSchedule> (couponList)); }
public async Task SaveTaskAsync(CouponSchedule item) { await couponTable.UpdateAsync(item); }