public static Notifications ParseJson(JToken json, string venueId, Model.CheckinRequest optionalCheckinRequest) { var ns = new Notifications(); ns._temporaryCheckinRequest = optionalCheckinRequest; // Save as a tombstoning object. var tt = new TombstoningText("notifications"); tt.Text = venueId + Environment.NewLine + json.ToString(); tt.Save(ns.UniqueId); foreach (var notif in json) { Notification notification = Notification.ParseJson(notif, venueId); if (notification != null) { ns.Add(notification); } else { string s = Json.TryGetJsonProperty(notif, "type"); if (s == "notificationTray") { var item = notif["item"]; if (item != null) { string unreadCount = Json.TryGetJsonProperty(item, "unreadCount"); int i; if (int.TryParse(unreadCount, out i)) { ns.UnreadNotifications = i; } } } } } // Reorder the notifications per Foursquare preferred ordering. int currentIndex = 0; TryReorderNotificationOfType(ns, typeof(MessageNotification), ref currentIndex); TryReorderNotificationOfType(ns, typeof(BadgeNotification), ref currentIndex); TryReorderNotificationOfType(ns, typeof(MayorshipNotification), ref currentIndex); TryReorderNotificationOfType(ns, typeof(SpecialNotification), ref currentIndex); TryReorderNotificationOfType(ns, typeof(ScoreNotification), ref currentIndex); TryReorderNotificationOfType(ns, typeof(LeaderboardNotification), ref currentIndex); TryReorderNotificationOfType(ns, typeof(RecommendedTipNotification), ref currentIndex); return(ns); }
private void DoQuickCheckin(Model.Venue venue) { // HORRIBLE... this code is just copied from Venue.xaml.cs string vid = venue.VenueId; // TODO: Actually this should show the check-in UI where you enter the information! Model.CheckinRequest request = null; // TODO: Use their defaults instead of false false!!! bool pingFacebook = false; bool pingTwitter = false; if (_settings != null && _settings.IsLoadComplete) { pingFacebook = _settings.SendToFacebook; pingTwitter = _settings.SendToTwitter; } request = Model.CheckinRequest.VenueCheckin(venue, pingTwitter, pingFacebook); FourSquare.Instance.Checkin(request, (success) => { // TODO: This is the check-in powerful stuff! // Need to reload the page itself to get the updated "here now" Dispatcher.BeginInvoke(() => { IntervalDispatcher. BeginInvoke( TimeSpan.FromSeconds(1.5), () => { // Refresh the checkins list. DataManager.Current.Refresh <Model.Checkins>("Checkins", null, null); }); }); }, (error) => { Dispatcher.BeginInvoke(() => { MessageBox.Show("We couldn't check you in now, sorry!"); }); }); }