public async Task ExecuteGetUserCommandAsync() { if (IsBusy) { return; } ProgressDialogManager.LoadProgressDialog("Loading..."); try { IsBusy = true; var user = await ParseAccess.GetUser(ParseAccess.CurrentUser().ObjectId); UserDetail = new User { Username = user.Get <string>("username"), FirstName = user.Get <string>("firstName"), LastName = user.Get <string>("lastName") }; } catch (Exception e) { Debug.WriteLine(e); } finally { IsBusy = false; ProgressDialogManager.DisposeProgressDialog(); } }
public async Task ExecuteLoadQuestionsCommandAsync(string filter) { if (IsBusy) { return; } ProgressDialogManager.LoadProgressDialog("Loading..."); try { IsBusy = true; Questions.Clear(); DateTime now = RestService.GetServerTime(); followedOppors.Clear(); try { followedOppors.AddRange((await ParseAccess.GetUser(ParseAccess.CurrentUser().ObjectId)).Get <IList <string> >("followedOppors")); } catch (Exception e) { Debug.WriteLine(e); } IEnumerable <Parse.ParseObject> questions; if (filter == "Followed Tasks") { questions = await ParseAccess.LoadFollowedOppors(followedOppors); } else if (filter == "Followed Topics") { questions = await ParseAccess.LoadOpporsBasedOnTopics(); } else if (filter == "My Requests") { questions = await ParseAccess.LoadMyRequests(); } else { questions = await ParseAccess.LoadQuestions(); } foreach (var question in questions) { var isFollowed = false; var state = "Closed"; var stateFlag = question.Get <int>("stateFlag"); var topicObjects = question.Get <IList <ParseObject> >("topics"); var topics = new List <string>(); foreach (var topic in topicObjects) { topics.Add(topic.Get <string>("topicText")); } if (stateFlag == (int)RequestState.Active) { state = "Active"; } else if (stateFlag == (int)RequestState.InProgress) { state = "In Progress"; } if (followedOppors.Contains(question.ObjectId)) { isFollowed = true; } var q = new Question { ObjectId = question.ObjectId, Title = question.Get <string>("title"), Body = question.Get <string>("body"), TimeAgo = HelperFunctions.TimeAgo(question.UpdatedAt.Value, now), IsFollowed = isFollowed, State = state, Topics = topics }; Questions.Add(q); } } catch (Exception e) { Debug.WriteLine(e); } finally { IsBusy = false; ProgressDialogManager.DisposeProgressDialog(); } }
public async Task ExecuteLoadUsersCommandAsync(string filter) { if (IsBusy) { return; } ProgressDialogManager.LoadProgressDialog("Loading..."); try { IsBusy = true; Users.Clear(); followedUsers.Clear(); try { followedUsers.AddRange((await ParseAccess.GetUser(ParseAccess.CurrentUser().ObjectId)).Get <IList <string> >("followedUsers")); } catch (Exception e) { Debug.WriteLine(e); } IEnumerable <Parse.ParseObject> users; if (filter == "Followed Users") { users = await ParseAccess.LoadFollowedUsers(followedUsers); } else { users = await ParseAccess.LoadUsers(); } foreach (var user in users) { var isFollowed = false; var topicObjects = user.Get <IList <ParseObject> >("followedTopics"); var topics = new List <string>(); foreach (var topic in topicObjects) { topics.Add(topic.Get <string>("topicText")); } if (followedUsers.Contains(user.ObjectId)) { isFollowed = true; } var u = new User { Username = user.Get <string>("username"), FirstName = user.Get <string>("firstName"), LastName = user.Get <string>("lastName"), ObjectId = user.ObjectId, IsFollowed = isFollowed, FollowedTopics = topics }; Users.Add(u); } } catch (Exception e) { Debug.WriteLine(e); } finally { IsBusy = false; ProgressDialogManager.DisposeProgressDialog(); } }