/// <summary> /// displays a persons activities or the activities that are available for them to sign up for /// </summary> /// <param name="isPersonActivities"></param> /// <param name="personID"></param> /// <returns></returns> public ActionResult PersonActivities(string email, bool isPersonActivities = true, string errorMessage = "") { email = User.Identity.Name; ViewBag.ErrorMessage = errorMessage; ViewBag.PersonID = email; ViewBag.IsPersonActivities = isPersonActivities; List <ActivityVM> activities; if (isPersonActivities) { var person = _userManager.RetrieveUserByID(_userManager.RetrieveUserIDFromEmail(email)); activities = _activityManager.RetrieveActivitiesByPersonID(_userManager.RetrieveUserIDFromEmail(email)); ViewBag.Title = person.FirstName + " " + person.LastName + "'s Activities"; } else { ViewBag.Title = "Available Activities"; activities = _activityManager.RetrieveAllActivitySchedulesByActive(); var personActivities = _activityManager.RetrieveActivitiesByPersonID(_userManager.RetrieveUserIDFromEmail(email)); foreach (var pa in personActivities) { for (int i = 0; i < activities.Count; i++) { if (pa.ActivityID == activities[i].ActivityID) { activities.Remove(activities[i]); } } } } return(View(activities)); }
// This helper method simply populates the dgUserActivityList with the appropriate data. private void populateUserActivityList() { //try //{ dgUserActivityList.ItemsSource = _activityManager?.RetrieveActivitiesByPersonID(_user.PersonID); //} //catch (Exception) { } }
// This event handler is fired when the sign up button is clicked. It signs the user up for an activity which indicates that they intend // to attend it. private void BtnSignUp_Click(object sender, RoutedEventArgs e) { try { if (dgActivityList.SelectedItems.Count == 0) { MessageBox.Show("You must make a selection\nfrom List of Upcoming Activities."); return; } if (_addMode) { return; } ActivityVM activity = (ActivityVM)dgActivityList.SelectedItem; var activities = _activityManager.RetrieveActivitiesByPersonID(_user.PersonID); foreach (var a in activities) { if (a.ActivityID == activity.ActivityID) { MessageBox.Show("You are already signed up for that activity."); return; } } if (MessageBox.Show("Are you sure?", "Sign up Activity", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { //chkActive.IsChecked = !(bool)chkActive.IsChecked; return; } try { activity = (ActivityVM)dgActivityList.SelectedItem; if (_activityManager.AddPersonActivity(_user.PersonID, activity.ActivityID)) { populatePeopleAttendingList(); populateUserActivityList(); } //populateUserActivityList(); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message); } } catch (Exception ex) { //MessageBox.Show("BAD"); } }
/// <summary> /// displays a persons profile page /// </summary> /// <param name="email"></param> /// <returns></returns> public ActionResult PersonProfile(string email) { email = User.Identity.Name; ViewBag.Title = "Your Profile"; var profile = new ProfileObject { Activities = _activityManager.RetrieveActivitiesByPersonID(_userManager.RetrieveUserIDFromEmail(email)), Groups = _userManager.RetrievePersonGroups(_userManager.RetrieveUserIDFromEmail(email)), Person = _userManager.RetrieveUserByID(_userManager.RetrieveUserIDFromEmail(email)) }; profile.Person.Roles = _userManager.RetrievePersonRoles(_userManager.RetrieveUserIDFromEmail(email)); return(View(profile)); }