public async Task <EventsRootObject> GetEvents(string groupId, int skip) { var offset = skip / 100; if (!await RenewAccessToken()) { messageDialog.SendToast("Unable to get events, please re-login."); return(new EventsRootObject() { Events = new List <Event>() }); } var client = CreateClient(); if (client.DefaultRequestHeaders.CacheControl == null) { client.DefaultRequestHeaders.CacheControl = new CacheControlHeaderValue(); } client.DefaultRequestHeaders.CacheControl.NoCache = true; client.DefaultRequestHeaders.IfModifiedSince = DateTime.UtcNow; client.DefaultRequestHeaders.CacheControl.NoStore = true; client.Timeout = new TimeSpan(0, 0, 30); var request = string.Format(GetEventsUrl, offset, groupId, Settings.AccessToken); if (!Settings.ShowAllEvents) { request += "&time=-100m,2m"; } var response = await client.GetStringAsync(request); return(await DeserializeObjectAsync <EventsRootObject>(response)); }
public async Task <GroupsRootObject> GetGroups(string memberId, int skip) { var offset = skip / 100; if (!await RenewAccessToken()) { messageDialog.SendToast("Unable to get groups, please re-login."); return(new GroupsRootObject { Groups = new List <Group>() }); } using (var client = CreateClient()) { if (client.DefaultRequestHeaders.CacheControl == null) { client.DefaultRequestHeaders.CacheControl = new CacheControlHeaderValue(); } client.DefaultRequestHeaders.CacheControl.NoCache = true; client.DefaultRequestHeaders.IfModifiedSince = DateTime.UtcNow; client.DefaultRequestHeaders.CacheControl.NoStore = true; client.Timeout = new TimeSpan(0, 0, 30); var request = string.Format(Settings.OrganizerMode ? GetGroupsOrganizerUrl : GetGroupsUrl, offset, memberId, Settings.AccessToken); var response = await client.GetStringAsync(request).ConfigureAwait(false); return(await DeserializeObjectAsync <GroupsRootObject>(response)); } }
private async void RenewAccessToken() { IsBusy = true; bool success = await meetupService.RenewAccessToken(); IsBusy = false; if (success) { ShowViewModel <GroupsViewModel>(); } else { dialog.SendToast("Please login again to re-validate credentials."); } }
/// <summary> /// Checks the banana. /// </summary> /// <returns><c>true</c>, if banana was checked, <c>false</c> otherwise.</returns> /// <param name="major">Major number of the beacon.</param> /// <param name="minor">Minor number of the beacon.</param> public void CheckBanana(int major, int minor) { if (major == 9999 && minor == 1000) { //Spy monkey found! pop up funny dialog here! return; } if (major == 9999 && major == 9999) { if (Settings.SecretBeaconFound) { return; } messages.SendMessage("Congratulations!", "You found the top secret hidden beacon and have unlocked a special prize at the end of your adventure!"); Settings.SecretBeaconFound = true; OnPropertyChanged(SecretBananaFoundPropertyName); return; } messages.SendToast("So close! Try another beacon."); }
protected override async Task ExecuteLoadMoreCommand() { if (!CanLoadMore || IsBusy) { return; } //Go to database and check this user in. IsBusy = true; try { var addNewMembers = Members.Count == 0; var eventResults = await this.meetupService.GetRSVPs(eventId, members.Count); foreach (var e in eventResults.RSVPs) { var member = new MemberViewModel(e.Member, e.MemberPhoto, eventId, eventName, groupId, groupName, eventDate); member.CheckedIn = await dataService.IsCheckedIn(eventId, member.Member.MemberId.ToString(), eventName, groupId, groupName, eventDate); members.Add(member); } CanLoadMore = eventResults.RSVPs.Count == 100; if (addNewMembers) { var newMembers = await dataService.GetNewMembers(eventId); foreach (var e in newMembers) { if (string.IsNullOrEmpty(e.GroupId)) { e.GroupId = groupId; e.GroupName = groupName; e.EventName = eventName; e.EventDate = eventDate; e.EventId = eventId; } var member = new MemberViewModel(new Member { MemberId = -1, Name = e.Name }, null, eventId, eventName, groupId, groupName, eventDate); member.NewUserId = e.Id; member.CheckedIn = true; members.Add(member); } } RefreshCount(); if (members.Count == 0) { messageDialog.SendToast("No one has checked in yet."); } } catch (Exception ex) { Mvx.Resolve <IMvxTrace>().Trace(MvxTraceLevel.Error, "EventViewModel", ex.ToString()); CanLoadMore = false; messageDialog.SendToast("Unable to get RSVPs please refresh or log in again."); } finally { IsBusy = false; } }
/// <summary> /// Checks the banana. /// </summary> /// <returns><c>true</c>, if banana was checked, <c>false</c> otherwise.</returns> /// <param name="major">Major number of the beacon.</param> /// <param name="minor">Minor number of the beacon.</param> public void CheckBeacon(int major, int minor) { if (major == 9999 && minor == 1000) { //Spy monkey found! pop up funny dialog here! return; } if (major == 9999 && major == 9999) { if (Settings.SecretBeaconFound) { return; } messages.SendMessage("Congratulations!", "You found the top secret hidden beacon and have unlocked a special prize at the end of your adventure!"); Settings.SecretBeaconFound = true; return; } bool found = true; try { if (quest == null) { return; } found = false; if (major != Quest.Major) { return; } foreach (Beacon beacon in Quest.Beacons) { if (beacon.Found) { if (beacon.Minor == minor) { found = true; } continue; } if (beacon.Minor == minor) { beacon.Found = true; OnPropertyChanged(QuestsPropertyName); //refresh bananas! CheckEndQuest(); found = true; } } } finally { if (!found) { messages.SendToast("So close! Try another beacon."); } } }