Exemple #1
0
        /// <summary>
        /// allows a user to sign up for or cancel being signed up for an activity
        /// </summary>
        /// <param name="signUp"></param>
        /// <param name="activityID"></param>
        /// <param name="personID"></param>
        /// <returns></returns>
        public ActionResult ActivitySignUpCancel(bool signUp, int activityID, string email)
        {
            string errorMessage     = "";
            bool   isPersonActivity = false;

            if (signUp)
            {
                try
                {
                    _activityManager.AddPersonActivity(_userManager.RetrieveUserIDFromEmail(email), activityID);
                    isPersonActivity = false;
                }
                catch (Exception)
                {
                    errorMessage = "Unable to add activity";
                }
            }
            else
            {
                try
                {
                    _activityManager.DeletePersonActivity(_userManager.RetrieveUserIDFromEmail(email), activityID);
                    isPersonActivity = true;
                }
                catch (Exception)
                {
                    errorMessage = "Unable to delete activity";
                }
            }
            return(RedirectToAction("PersonActivities", new { email = email, isPersonActivities = isPersonActivity, errorMessage = errorMessage }));
        }
Exemple #2
0
        // 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");
            }
        }