当前位置: 首页>>代码示例>>C#>>正文


C# GroupMemberService.First方法代码示例

本文整理汇总了C#中Rock.Model.GroupMemberService.First方法的典型用法代码示例。如果您正苦于以下问题:C# GroupMemberService.First方法的具体用法?C# GroupMemberService.First怎么用?C# GroupMemberService.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rock.Model.GroupMemberService的用法示例。


在下文中一共展示了GroupMemberService.First方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowForm

        /// <summary>
        /// Shows the view.
        /// </summary>
        private void ShowForm()
        {
            lReceipt.Visible = false;
            pnlAddPledge.Visible = true;

            if ( CurrentPerson != null )
            {
                lName.Text = CurrentPerson.FullName;
                lName.Visible = true;

                tbFirstName.Visible = false;
                tbLastName.Visible = false;
                tbEmail.Visible = false;

                using ( var rockContext = new RockContext() )
                {
                    Guid? groupTypeGuid = GetAttributeValue( "SelectGroupType" ).AsGuidOrNull();
                    if ( groupTypeGuid.HasValue )
                    {
                        var groups = new GroupMemberService( rockContext )
                            .Queryable().AsNoTracking()
                            .Where( m =>
                                m.Group.GroupType.Guid == groupTypeGuid.Value &&
                                m.PersonId == CurrentPerson.Id &&
                                m.GroupMemberStatus == GroupMemberStatus.Active &&
                                m.Group.IsActive )
                            .Select( m => new
                            {
                                m.GroupId,
                                Name = m.Group.Name,
                                GroupTypeName = m.Group.GroupType.Name
                            } )
                            .ToList()
                            .Distinct()
                            .OrderBy( g => g.Name )
                            .ToList();
                        if ( groups.Any() )
                        {
                            ddlGroup.Label = "For " + groups.First().GroupTypeName;
                            ddlGroup.DataSource = groups;
                            ddlGroup.DataBind();
                            ddlGroup.Visible = true;
                        }
                        else
                        {
                            ddlGroup.Visible = false;
                        }
                    }
                    else
                    {
                        ddlGroup.Visible = false;
                    }
                }
            }
            else
            {
                lName.Visible = false;
                ddlGroup.Visible = false;

                tbFirstName.Visible = true;
                tbLastName.Visible = true;
                tbEmail.Visible = true;

                tbFirstName.Text = string.Empty;
                tbLastName.Text = string.Empty;
                tbEmail.Text = string.Empty;
            }

            // Warn if Financial Account is not specified (must be set up by administrator)
            var financialAccount = new FinancialAccountService( new RockContext() ).Get( GetAttributeValue( "Account" ).AsGuid() );
            if ( financialAccount == null )
            {
                nbWarningMessage.Text = "Warning: No Account is specified for this pledge.  Please contact the administrator.";
                nbWarningMessage.Visible = true;
            }
            else
            {
                nbWarningMessage.Visible = false;
            }

            drpDateRange.DelimitedValues = GetAttributeValue( "PledgeDateRange" );

            // only show the date range picker if the block setting for date range isn't fully specified
            drpDateRange.Visible = drpDateRange.LowerValue == null || drpDateRange.UpperValue == null;

            ddlFrequency.Items.Clear();
            var frequencies = DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.FINANCIAL_FREQUENCY.AsGuid() ).DefinedValues.OrderBy( a => a.Order ).ThenBy( a => a.Value );
            foreach ( var frequency in frequencies )
            {
                ddlFrequency.Items.Add( new ListItem( frequency.Value, frequency.Id.ToString() ) );
            }

            ddlFrequency.Visible = GetAttributeValue( "ShowPledgeFrequency" ).AsBooleanOrNull() ?? false;
            ddlFrequency.SelectedValue = null;

            // if Frequency is Visible, require it if RequirePledgeFrequency
            ddlFrequency.Required = ddlFrequency.Visible && ( GetAttributeValue( "RequirePledgeFrequency" ).AsBooleanOrNull() ?? false );
//.........这里部分代码省略.........
开发者ID:NewSpring,项目名称:Rock,代码行数:101,代码来源:PledgeEntry.ascx.cs


注:本文中的Rock.Model.GroupMemberService.First方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。