Beispiel #1
0
        /// <summary>
        /// Handles the Delete event of the gCampuses control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
        protected void gCampuses_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            CampusService campusService = new CampusService( rockContext );
            Campus campus = campusService.Get( e.RowKeyId );
            if ( campus != null )
            {
                // Don't allow deleting the last campus
                if ( !campusService.Queryable().Where( c => c.Id != campus.Id ).Any() )
                {
                    mdGridWarning.Show( campus.Name + " is the only campus and cannot be deleted (Rock requires at least one campus).", ModalAlertType.Information );
                    return;
                }

                string errorMessage;
                if ( !campusService.CanDelete( campus, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                CampusCache.Flush( campus.Id );

                campusService.Delete( campus );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
Beispiel #2
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="businessId">The business identifier.</param>
        public void ShowDetail( int businessId )
        {
            var rockContext = new RockContext();

            // Load the Campus drop down
            ddlCampus.Items.Clear();
            ddlCampus.Items.Add( new ListItem( string.Empty, string.Empty ) );
            var campusService = new CampusService( new RockContext() );
            foreach ( Campus campus in campusService.Queryable() )
            {
                ListItem li = new ListItem( campus.Name, campus.Id.ToString() );
                ddlCampus.Items.Add( li );
            }

            Person business = null;     // A business is a person

            if ( !businessId.Equals( 0 ) )
            {
                business = new PersonService( rockContext ).Get( businessId );
            }

            if ( business == null )
            {
                business = new Person { Id = 0, Guid = Guid.NewGuid() };
            }

            bool editAllowed = business.IsAuthorized( Authorization.EDIT, CurrentPerson );

            hfBusinessId.Value = business.Id.ToString();

            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if ( !editAllowed || !IsUserAuthorized( Authorization.EDIT ) )
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed( Person.FriendlyTypeName );
            }

            if ( readOnly )
            {
                ShowSummary( businessId );
            }
            else
            {
                if ( business.Id > 0 )
                {
                    ShowSummary( business.Id );
                }
                else
                {
                    ShowEditDetails( business );
                }
            }

            BindContactListGrid( business );
        }
Beispiel #3
0
        /// <summary>
        /// Creates the control(s) neccessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override System.Web.UI.Control EditControl( Dictionary<string, ConfigurationValue> configurationValues, string id )
        {
            var editControl = new RockDropDownList { ID = id }; 

            CampusService campusService = new CampusService();
            var campusList = campusService.Queryable().OrderBy( a => a.Name ).ToList();
            editControl.Items.Add( None.ListItem );
            foreach ( var campus in campusList )
            {
                editControl.Items.Add( new ListItem( campus.Name, campus.Id.ToString() ) );
            }

            return editControl;
        }
Beispiel #4
0
        /// <summary>
        /// Creates the control(s) neccessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override System.Web.UI.Control EditControl( Dictionary<string, ConfigurationValue> configurationValues, string id )
        {
            var campusPicker = new CampusPicker { ID = id };

            CampusService campusService = new CampusService( new RockContext() );
            var campusList = campusService.Queryable().OrderBy( a => a.Name ).ToList();

            if ( campusList.Any() )
            {
                campusPicker.Campuses = campusList;
                return campusPicker;
            }

            return null;
        }
        /// <summary>
        /// Loads the campus picker.
        /// </summary>
        private void LoadCampusPicker()
        {
            CampusService campusService = new CampusService( new RockContext() );

            cpCampuses.Campuses = campusService.Queryable().OrderBy( a => a.Name ).ToList();
            cpCampuses.Visible = cpCampuses.AvailableCampusIds.Count > 0;
        }
        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            CampusService campusService = new CampusService( new RockContext() );
            SortProperty sortProperty = gCampuses.SortProperty;

            if ( sortProperty != null )
            {
                gCampuses.DataSource = campusService.Queryable().Sort( sortProperty ).ToList();
            }
            else
            {
                gCampuses.DataSource = campusService.Queryable().OrderBy( s => s.Name ).ToList();
            }

            gCampuses.DataBind();
        }
 /// <summary>
 /// Loads the drop downs.
 /// </summary>
 private void LoadDropDowns()
 {
     CampusService campusService = new CampusService( new RockContext() );
     List<Campus> campuses = campusService.Queryable().OrderBy( a => a.Name ).ToList();
     campuses.Insert( 0, new Campus { Id = None.Id, Name = None.Text } );
     ddlCampus.DataSource = campuses;
     ddlCampus.DataBind();
 }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad( EventArgs e )
        {
            base.OnLoad( e );

            if ( !Page.IsPostBack )
            {
                var rockContext = new RockContext();
                string itemId = PageParameter( "businessId" );

                // Load the Giving Group drop down
                ddlGivingGroup.Items.Clear();
                ddlGivingGroup.Items.Add( new ListItem( None.Text, None.IdValue ) );
                if ( int.Parse( itemId ) > 0 )
                {
                    var businessService = new PersonService( rockContext );
                    var business = businessService.Get( int.Parse( itemId ) );
                    ddlGivingGroup.Items.Add( new ListItem( business.FirstName, business.Id.ToString() ) );
                }

                // Load the Campus drop down
                ddlCampus.Items.Clear();
                ddlCampus.Items.Add( new ListItem( string.Empty, string.Empty ) );
                var campusService = new CampusService( new RockContext() );
                foreach ( Campus campus in campusService.Queryable() )
                {
                    ListItem li = new ListItem( campus.Name, campus.Id.ToString() );
                    ddlCampus.Items.Add( li );
                }

                if ( !string.IsNullOrWhiteSpace( itemId ) )
                {
                    ShowDetail( "businessId", int.Parse( itemId ) );
                }
                else
                {
                    pnlDetails.Visible = false;
                }
            }

            if ( !string.IsNullOrWhiteSpace( hfModalOpen.Value ) )
            {
                mdAddContact.Show();
            }
        }
        /// <summary>
        /// Loads the drop downs.
        /// </summary>
        private void LoadDropDowns()
        {
            // Controls on Main Campaign Panel
            GroupService groupService = new GroupService();
            List<Group> groups = groupService.Queryable().Where( a => a.GroupType.Guid.Equals( new Guid( Rock.SystemGuid.GroupType.GROUPTYPE_EVENTATTENDEES ) ) ).OrderBy( a => a.Name ).ToList();
            groups.Insert( 0, new Group { Id = None.Id, Name = None.Text } );
            ddlEventGroup.DataSource = groups;
            ddlEventGroup.DataBind();

            CampusService campusService = new CampusService();

            cpCampuses.Campuses = campusService.Queryable().OrderBy( a => a.Name ).ToList();
            cpCampuses.Visible = cpCampuses.AvailableCampusIds.Count > 0;
        }
Beispiel #10
0
    /// <summary>
    /// Loads the drop downs.
    /// </summary>
    private void LoadDropDowns()
    {
        GroupTypeService groupTypeService = new GroupTypeService();
        var groupTypeQry = groupTypeService.Queryable();

        // limit GroupType selection to what Block Attributes allow
        List<int> groupTypeIds = AttributeValue( "GroupTypes" ).SplitDelimitedValues().Select( a => int.Parse( a ) ).ToList();
        if ( groupTypeIds.Count > 0 )
        {
            groupTypeQry = groupTypeQry.Where( a => groupTypeIds.Contains( a.Id ) );
        }

        List<GroupType> groupTypes = groupTypeQry.OrderBy( a => a.Name ).ToList();
        ddlGroupType.DataSource = groupTypes;
        ddlGroupType.DataBind();

        int currentGroupId = int.Parse( hfGroupId.Value );

        // TODO: Only include valid Parent choices (no circular references)
        GroupService groupService = new GroupService();
        List<Group> groups = groupService.Queryable().Where( g => g.Id != currentGroupId ).OrderBy( a => a.Name ).ToList();
        groups.Insert( 0, new Group { Id = None.Id, Name = None.Text } );
        ddlParentGroup.DataSource = groups;
        ddlParentGroup.DataBind();

        CampusService campusService = new CampusService();
        List<Campus> campuses = campusService.Queryable().OrderBy( a => a.Name ).ToList();
        campuses.Insert( 0, new Campus { Id = None.Id, Name = None.Text } );
        ddlCampus.DataSource = campuses;
        ddlCampus.DataBind();
    }
        /// <summary>
        /// Loads the drop downs.
        /// </summary>
        private void LoadDropDowns()
        {
            // Controls on Main Campaign Panel
            GroupService groupService = new GroupService();
            List<Group> groups = groupService.Queryable().Where( a => a.GroupType.Guid.Equals( Rock.SystemGuid.GroupType.GROUPTYPE_EVENTATTENDEES ) ).OrderBy( a => a.Name ).ToList();
            groups.Insert( 0, new Group { Id = None.Id, Name = None.Text } );
            ddlEventGroup.DataSource = groups;
            ddlEventGroup.DataBind();

            PersonService personService = new PersonService();
            List<Person> persons = personService.Queryable().OrderBy( a => a.NickName ).ThenBy( a => a.LastName ).ToList();
            persons.Insert( 0, new Person { Id = None.Id, GivenName = None.Text } );
            ddlContactPerson.DataSource = persons;
            ddlContactPerson.DataBind();

            CampusService campusService = new CampusService();

            cpCampuses.Campuses = campusService.Queryable().OrderBy( a => a.Name ).ToList(); ;

            // Controls on Ad Child Panel
            MarketingCampaignAdTypeService marketingCampaignAdTypeService = new MarketingCampaignAdTypeService();
            var adtypes = marketingCampaignAdTypeService.Queryable().OrderBy( a => a.Name ).ToList();
            ddlMarketingCampaignAdType.DataSource = adtypes;
            ddlMarketingCampaignAdType.DataBind();
        }
Beispiel #12
0
        /// <summary>
        /// Binds the filter.
        /// </summary>
        private void BindFilter()
        {
            txtAccountName.Text = rAccountFilter.GetUserPreference( "Account Name" );
            var campusService = new CampusService( new RockContext() );
            ddlCampus.Items.Add( new ListItem( string.Empty, string.Empty ) );
            foreach ( Campus campus in campusService.Queryable() )
            {
                ListItem li = new ListItem( campus.Name, campus.Id.ToString() );
                li.Selected = campus.Id.ToString() == rAccountFilter.GetUserPreference( "Campus" );
                ddlCampus.Items.Add( li );
            }

            ddlIsActive.SelectedValue = rAccountFilter.GetUserPreference( "Active" );
            ddlIsTaxDeductible.SelectedValue = rAccountFilter.GetUserPreference( "Tax Deductible" );
        }
        protected void mdCampus_OnSaveClick(object sender, EventArgs e)
        {
            GroupService groupService = new GroupService(rockContext);
            CampusService campusService = new CampusService(rockContext);

            var personFamily = _targetPerson.GetFamilies(rockContext).FirstOrDefault();

            var theGroup = groupService.Queryable().Where(a => a.Id == personFamily.Id).FirstOrDefault();

            var theCampus = campusService.Queryable().Where(c => c.Name == cpCampus.SelectedValue).FirstOrDefault();

            theGroup.Campus = theCampus;

            rockContext.SaveChanges();

            mdCampus.Hide();
        }