Пример #1
0
        /// <summary>
        /// Handles the ItemCommand event of the control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RepeaterCommandEventArgs"/> instance containing the event data.</param>
        protected void rptProjects_ItemCommand(object Sender, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "Close")
            {
                var notificationRecipientGuid = e.CommandArgument.ToString().AsGuidOrNull();
                if (notificationRecipientGuid.HasValue)
                {
                    var rockContext = new RockContext();
                    var notificationRecipientService = new NotificationRecipientService(rockContext);
                    var notificationItem             = notificationRecipientService.Get(notificationRecipientGuid.Value);
                    if (notificationItem != null)
                    {
                        notificationItem.Read         = true;
                        notificationItem.ReadDateTime = RockDateTime.Now;
                    }

                    var toHide = e.Item.FindControl("rptNotificationAlert");
                    if (toHide != null)
                    {
                        toHide.Visible = false;
                    }

                    rockContext.SaveChanges();

                    NotificationCount--;
                    if (NotificationCount == 0)
                    {
                        HidePanel();
                    }
                }
            }
        }
Пример #2
0
        protected void rptProjects_ItemCommand( object Sender, RepeaterCommandEventArgs e )
        {
            if ( e.CommandName == "Close" )
            {
                var notificationRecipientGuid = e.CommandArgument.ToString().AsGuidOrNull();
                if ( notificationRecipientGuid.HasValue )
                {
                    var rockContext = new RockContext();
                    var notificationRecipientService = new NotificationRecipientService( rockContext );
                    var notificationItem = notificationRecipientService.Get( notificationRecipientGuid.Value );
                    if ( notificationItem != null )
                    {
                        notificationRecipientService.Delete( notificationItem );
                    }

                    var toHide = e.Item.FindControl( "rptNotificationAlert" );
                    if ( toHide != null )
                    {
                        toHide.Visible = false;
                    }

                    rockContext.SaveChanges();

                    NotificationCount--;
                    if (NotificationCount == 0 )
                    {
                        HidePanel();
                    }
                }
            }
        }