Beispiel #1
0
        /// <summary>
        /// Adds the user.
        /// </summary>
        /// <param name="s">The s.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void AddProjectNotification(Object s, EventArgs e)
        {
            //The users must be added to a list first because the collection can not
            //be modified while we iterate through it.
            var usersToAdd = lstAllProjects.Items.Cast <ListItem>().Where(item => item.Selected).ToList();

            foreach (var item in usersToAdd)
            {
                var notification = new ProjectNotification
                {
                    ProjectId            = Convert.ToInt32(item.Value),
                    NotificationUsername = Security.GetUserName()
                };

                if (!ProjectNotificationManager.SaveOrUpdate(notification))
                {
                    continue;
                }

                lstSelectedProjects.Items.Add(item);
                lstAllProjects.Items.Remove(item);
            }

            lstSelectedProjects.SelectedIndex = -1;
        }
        /// <summary>
        /// Removes the user.
        /// </summary>
        /// <param name="s">The s.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void RemoveUser(Object s, EventArgs e)
        {
            //The users must be added to a list first becuase the collection can not
            //be modified while we iterate through it.
            var usersToRemove = lstSelectedUsers.Items.Cast <ListItem>().Where(item => item.Selected).ToList();

            foreach (var item in usersToRemove)
            {
                if (ProjectNotificationManager.Delete(ProjectId, item.Value))
                {
                    lstAllUsers.Items.Add(item);
                    lstSelectedUsers.Items.Remove(item);
                }
            }

            lstAllUsers.SelectedIndex = -1;
        }
Beispiel #3
0
        /// <summary>
        /// Removes the user.
        /// </summary>
        /// <param name="s">The s.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void RemoveProjectNotification(Object s, EventArgs e)
        {
            //The users must be added to a list first because the collection can not
            //be modified while we iterate through it.
            var usersToRemove = lstSelectedProjects.Items.Cast <ListItem>().Where(item => item.Selected).ToList();

            foreach (var item in usersToRemove)
            {
                if (!ProjectNotificationManager.Delete(Convert.ToInt32(item.Value), Security.GetUserName()))
                {
                    continue;
                }
                lstAllProjects.Items.Add(item);
                lstSelectedProjects.Items.Remove(item);
            }

            lstAllProjects.SelectedIndex = -1;
        }
Beispiel #4
0
        protected void BulletedList4_Click1(object sender, BulletedListEventArgs e)
        {
            //Label1.Text = "The Index of Item you clicked: " + e.Index + "<br> The value of Item you clicked: " + BulletedList4.Items[e.Index].Text;
            foreach (ListItem li in BulletedList4.Items)
            {
                li.Attributes.Add("class", "");
            }

            BulletedList4.Items[e.Index].Attributes.Add("class", "active");

            ProfileView.ActiveViewIndex = e.Index;
            var userName = Security.GetUserName();

            switch (ProfileView.ActiveViewIndex)
            {
            case 2:
                lstAllProjects.Items.Clear();
                lstSelectedProjects.Items.Clear();
                lstAllProjects.DataSource     = ProjectManager.GetByMemberUserName(userName);
                lstAllProjects.DataTextField  = "Name";
                lstAllProjects.DataValueField = "Id";
                lstAllProjects.DataBind();

                // Copy selected users into Selected Users List Box
                var projectNotifications = ProjectNotificationManager.GetByUsername(userName);

                foreach (var currentNotification in projectNotifications)
                {
                    var matchItem = lstAllProjects.Items.FindByValue(currentNotification.ProjectId.ToString());
                    if (matchItem == null)
                    {
                        continue;
                    }

                    lstSelectedProjects.Items.Add(matchItem);
                    lstAllProjects.Items.Remove(matchItem);
                }
                break;
            }
        }
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        public void Initialize()
        {
            lstAllUsers.Items.Clear();
            lstSelectedUsers.Items.Clear();

            lstAllUsers.DataSource     = UserManager.GetUsersByProjectId(ProjectId);
            lstAllUsers.DataTextField  = "DisplayName";
            lstAllUsers.DataValueField = "Username";
            lstAllUsers.DataBind();

            // Copy selected users into Selected Users List Box
            IEnumerable <ProjectNotification> projectNotifications = ProjectNotificationManager.GetByProjectId(ProjectId);

            foreach (ProjectNotification currentNotification in projectNotifications)
            {
                ListItem matchItem = lstAllUsers.Items.FindByValue(currentNotification.NotificationUsername);
                if (matchItem != null)
                {
                    lstSelectedUsers.Items.Add(matchItem);
                    lstAllUsers.Items.Remove(matchItem);
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Binds the notifications.
        /// </summary>
        private void BindNotifications()
        {
            NotificationsDataGrid.DataSource = IssueNotificationManager.GetByIssueId(IssueId);
            NotificationsDataGrid.DataBind();

            lstProjectUsers.DataSource = UserManager.GetUsersByProjectId(ProjectId);
            lstProjectUsers.DataBind();

            List <ProjectNotification> projectNotifications = (List <ProjectNotification>)ProjectNotificationManager.GetByProjectId(ProjectId);
            List <IssueNotification>   CurrentUsers         = IssueNotificationManager.GetByIssueId(IssueId);

            foreach (IssueNotification item in CurrentUsers)
            {
                if (lstProjectUsers.Items.FindByValue(item.NotificationUsername) != null)
                {
                    ListItem DelIndex = null;
                    DelIndex = lstProjectUsers.Items.FindByValue(item.NotificationUsername);
                    lstProjectUsers.Items.Remove(DelIndex);
                }
            }

            lstNotificationUsers.DataSource = CurrentUsers;
            lstNotificationUsers.DataBind();

            // filter out project notifications and disable them
            foreach (ListItem item in lstNotificationUsers.Items)
            {
                if (projectNotifications.Any(p => p.NotificationUsername == item.Value))
                {
                    item.Attributes.Add("disabled", "disabled");
                    item.Text += GetLocalResourceObject("ProjectLevel").ToString();
                }
            }
        }