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


C# Model.ScheduleService类代码示例

本文整理汇总了C#中Rock.Model.ScheduleService的典型用法代码示例。如果您正苦于以下问题:C# ScheduleService类的具体用法?C# ScheduleService怎么用?C# ScheduleService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ScheduleService类属于Rock.Model命名空间,在下文中一共展示了ScheduleService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FormatValue

        /// <summary>
        /// Returns the field's current value(s)
        /// </summary>
        /// <param name="parentControl">The parent control.</param>
        /// <param name="value">Information about the value</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
        /// <returns></returns>
        public override string FormatValue( Control parentControl, string value, Dictionary<string, ConfigurationValue> configurationValues, bool condensed )
        {
            string formattedValue = string.Empty;

            if ( !string.IsNullOrWhiteSpace( value ) )
            {
                var names = new List<string>();
                var guids = new List<Guid>();

                foreach ( string guidValue in value.Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries ) )
                {
                    Guid? guid = guidValue.AsGuidOrNull();
                    if ( guid.HasValue )
                    {
                        guids.Add( guid.Value );
                    }
                }

                if ( guids.Any() )
                {
                    var schedules = new ScheduleService( new RockContext() ).Queryable().Where( a => guids.Contains( a.Guid ) );
                    if ( schedules.Any() )
                    {
                        formattedValue = string.Join( ", ", ( from schedule in schedules select schedule.Name ).ToArray() );
                    }
                }
            }

            return base.FormatValue( parentControl, formattedValue, null, condensed );
        }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:38,代码来源:SchedulesFieldType.cs

示例2: OnLoad

        protected override void OnLoad( EventArgs e )
        {
            base.OnLoad( e );

            var scheduleGuids = GetAttributeValue( "LiveSchedule" );

            // Check to make sure that scheduleGuids is not null
            if ( scheduleGuids != null )
            {
                var scheduleArray = scheduleGuids.Split( ',' ).AsGuidList();

                var scheduleService = new ScheduleService( new RockContext() );

                // Support for multiples schedules loops through each
                foreach ( var scheduleGuid in scheduleArray )
                {
                    var schedule = new ScheduleService( new RockContext() ).Get( scheduleGuid );

                    if ( schedule != null )
                    {
                        var scheduleExpired = schedule.IsValid;

                        bool scheduleActive = schedule.IsScheduleOrCheckInActive;

                        // Check if Check in or Schedule is active and set the state accordingly
                        if ( scheduleActive )
                        {
                            // Active Schedule, set liveFeedStatus to on
                            liveFeedStatus.Value = "on";

                            liveHeading.Text = BlockName;

                            // Get the ip address
                            String currentIp = GetLanIPAddress();

                            String internalIp = "204.116.47.244";

                            if ( currentIp == internalIp )
                            {
                                localIP.Value = "true";
                            }
                            else
                            {
                                localIP.Value = "false";
                            }

                            break;
                        }
                        else
                        {
                            liveFeedStatus.Value = "off";
                        }
                    }
                    else
                    {
                        liveFeedStatus.Value = "off";
                    }
                }
            }
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:60,代码来源:AllStaffLive.ascx.cs

示例3: ShowDetail

        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        /// <param name="parentCategoryId">The parent category id.</param>
        public void ShowDetail( string itemKey, int itemKeyValue, int? parentCategoryId )
        {
            pnlDetails.Visible = false;
            if ( itemKey != "ScheduleId" )
            {
                return;
            }

            var scheduleService = new ScheduleService( new RockContext() );
            Schedule schedule = null;

            if ( !itemKeyValue.Equals( 0 ) )
            {
                schedule = scheduleService.Get( itemKeyValue );
            }
            else
            {
                schedule = new Schedule { Id = 0, CategoryId = parentCategoryId };
            }

            if ( schedule == null )
            {
                return;
            }

            pnlDetails.Visible = true;
            hfScheduleId.Value = schedule.Id.ToString();

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

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

            if ( readOnly )
            {
                btnEdit.Visible = false;
                btnDelete.Visible = false;
                ShowReadonlyDetails( schedule );
            }
            else
            {
                btnEdit.Visible = true;
                string errorMessage = string.Empty;
                btnDelete.Visible = scheduleService.CanDelete( schedule, out errorMessage );
                if ( schedule.Id > 0 )
                {
                    ShowReadonlyDetails( schedule );
                }
                else
                {
                    ShowEditDetails( schedule );
                }
            }
        }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:65,代码来源:ScheduleDetail.ascx.cs

示例4: ShowDetail

        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="scheduleId">The schedule identifier.</param>
        /// <param name="parentCategoryId">The parent category id.</param>
        public void ShowDetail( int scheduleId, int? parentCategoryId )
        {
            pnlDetails.Visible = false;

            var scheduleService = new ScheduleService( new RockContext() );
            Schedule schedule = null;

            if ( !scheduleId.Equals( 0 ) )
            {
                schedule = scheduleService.Get( scheduleId );
                pdAuditDetails.SetEntity( schedule, ResolveRockUrl( "~" ) );
            }

            if ( schedule == null )
            {
                schedule = new Schedule { Id = 0, CategoryId = parentCategoryId };
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            pnlDetails.Visible = true;
            hfScheduleId.Value = schedule.Id.ToString();

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

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

            if ( readOnly )
            {
                btnEdit.Visible = false;
                btnDelete.Visible = false;
                ShowReadonlyDetails( schedule );
            }
            else
            {
                btnEdit.Visible = true;
                string errorMessage = string.Empty;
                btnDelete.Visible = scheduleService.CanDelete( schedule, out errorMessage );
                if ( schedule.Id > 0 )
                {
                    ShowReadonlyDetails( schedule );
                }
                else
                {
                    ShowEditDetails( schedule );
                }
            }
        }
开发者ID:SparkDevNetwork,项目名称:Rock,代码行数:59,代码来源:ScheduleDetail.ascx.cs

示例5: AddScheduleColumns

        /// <summary>
        /// Adds the schedule columns.
        /// </summary>
        private void AddScheduleColumns()
        {
            ScheduleService scheduleService = new ScheduleService();

            // limit Schedules to ones that have a CheckInStartOffsetMinutes
            var scheduleQry = scheduleService.Queryable().Where( a => a.CheckInStartOffsetMinutes != null );

            // limit Schedules to the Category from the Filter
            int scheduleCategoryId = rFilter.GetUserPreference( "Category" ).AsInteger() ?? Rock.Constants.All.Id;
            if ( scheduleCategoryId != Rock.Constants.All.Id )
            {
                scheduleQry = scheduleQry.Where( a => a.CategoryId == scheduleCategoryId );
            }
            else
            {
                // NULL (or 0) means Shared, so specifically filter so to show only Schedules with CategoryId NULL
                scheduleQry = scheduleQry.Where( a => a.CategoryId == null );
            }

            // clear out any existing schedule columns and add the ones that match the current filter setting
            var scheduleList = scheduleQry.ToList().OrderBy( a => a.ToString() ).ToList();

            var checkBoxEditableFields = gGroupLocationSchedule.Columns.OfType<CheckBoxEditableField>().ToList();
            foreach ( var field in checkBoxEditableFields )
            {
                gGroupLocationSchedule.Columns.Remove( field );
            }

            foreach ( var item in scheduleList )
            {
                string dataFieldName = string.Format( "scheduleField_{0}", item.Id );

                CheckBoxEditableField field = new CheckBoxEditableField { HeaderText = item.Name, DataField = dataFieldName };
                gGroupLocationSchedule.Columns.Add( field );
            }

            if ( !scheduleList.Any() )
            {
                nbNotification.Text = nbNotification.Text = String.Format( "<p><strong>Warning</strong></p>No schedules found. Consider <a class='alert-link' href='{0}'>adding a schedule</a> or a different schedule category.", ResolveUrl( "~/Schedules" ) );
                nbNotification.Visible = true;
            }
            else
            {
                nbNotification.Visible = false;
            }
        }
开发者ID:pkdevbox,项目名称:Rock,代码行数:49,代码来源:CheckinScheduleBuilder.ascx.cs

示例6: gSchedules_Delete

        /// <summary>
        /// Handles the Delete event of the gSchedules 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 gSchedules_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            ScheduleService scheduleService = new ScheduleService( rockContext );
            Schedule schedule = scheduleService.Get( e.RowKeyId );
            if ( schedule != null )
            {
                string errorMessage;
                if ( !scheduleService.CanDelete( schedule, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                scheduleService.Delete( schedule );
                rockContext.SaveChanges();
            }

            BindGrid();
        }
开发者ID:RMRDevelopment,项目名称:Rockit,代码行数:25,代码来源:ScheduleList.ascx.cs

示例7: BindGrid

        /// <summary>
        /// Binds the group members grid.
        /// </summary>
        protected void BindGrid()
        {
            if ( _group != null )
            {
                lHeading.Text = _group.Name;

                var qry = new ScheduleService( _rockContext ).GetGroupOccurrences( _group ).AsQueryable();

                SortProperty sortProperty = gOccurrences.SortProperty;
                List<ScheduleOccurrence> occurrences = null;
                if ( sortProperty != null )
                {
                    occurrences = qry.Sort( sortProperty ).ToList();
                }
                else
                {
                    occurrences = qry.OrderByDescending( a => a.StartDateTime ).ToList();
                }

                gOccurrences.DataSource = occurrences;
                gOccurrences.DataBind();
            }
        }
开发者ID:Higherbound,项目名称:Higherbound-2016-website-upgrades,代码行数:26,代码来源:GroupAttendanceList.ascx.cs

示例8: gGroupLocationSchedule_RowDataBound

        /// <summary>
        /// Handles the RowDataBound event of the gGroupLocationSchedule control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GridViewRowEventArgs"/> instance containing the event data.</param>
        protected void gGroupLocationSchedule_RowDataBound( object sender, GridViewRowEventArgs e )
        {
            // add tooltip to header columns
            if ( e.Row.RowType == DataControlRowType.Header )
            {
                var scheduleService = new ScheduleService( new RockContext() );

                foreach ( var cell in e.Row.Cells.OfType<DataControlFieldCell>() )
                {
                    if ( cell.ContainingField is CheckBoxEditableField )
                    {
                        CheckBoxEditableField checkBoxEditableField = cell.ContainingField as CheckBoxEditableField;
                        int scheduleId = int.Parse( checkBoxEditableField.DataField.Replace( "scheduleField_", string.Empty ) );

                        var schedule = scheduleService.Get( scheduleId );
                        if ( schedule != null )
                        {
                            cell.Attributes["title"] = schedule.ToString();
                        }
                    }
                }
            }
        }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:28,代码来源:CheckinScheduleBuilder.ascx.cs

示例9: BindGrid

        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            ScheduleService scheduleService = new ScheduleService( new RockContext() );
            SortProperty sortProperty = gSchedules.SortProperty;
            var qry = scheduleService.Queryable().Select( a =>
                new
                {
                    a.Id,
                    a.Name,
                    CategoryName = a.Category.Name
                } );

            if ( sortProperty != null )
            {
                gSchedules.DataSource = qry.Sort( sortProperty ).ToList();
            }
            else
            {
                gSchedules.DataSource = qry.OrderBy( s => s.Name ).ToList();
            }

            gSchedules.EntityTypeId = EntityTypeCache.Read<Schedule>().Id;
            gSchedules.DataBind();
        }
开发者ID:RMRDevelopment,项目名称:Rockit,代码行数:27,代码来源:ScheduleList.ascx.cs

示例10: btnSave_Click


//.........这里部分代码省略.........
                metric.DataViewId = null;
            }

            var scheduleSelectionType = rblScheduleSelect.SelectedValueAsEnum<ScheduleSelectionType>();
            if ( scheduleSelectionType == ScheduleSelectionType.NamedSchedule )
            {
                metric.ScheduleId = ddlSchedule.SelectedValueAsId();
            }
            else
            {
                metric.ScheduleId = hfUniqueScheduleId.ValueAsInt();
            }

            if ( !Page.IsValid )
            {
                return;
            }

            if ( !metric.IsValid )
            {
                // Controls will render the error messages
                return;
            }

            if ( !cpMetricCategories.SelectedValuesAsInt().Any() )
            {
                cpMetricCategories.ShowErrorMessage( "Must select at least one category" );
                return;
            }

            // do a WrapTransaction since we are doing multiple SaveChanges()
            rockContext.WrapTransaction( () =>
            {
                var scheduleService = new ScheduleService( rockContext );
                var schedule = scheduleService.Get( metric.ScheduleId ?? 0 );
                int metricScheduleCategoryId = new CategoryService( rockContext ).Get( Rock.SystemGuid.Category.SCHEDULE_METRICS.AsGuid() ).Id;
                if ( schedule == null )
                {
                    schedule = new Schedule();

                    // make it an "Unnamed" metrics schedule
                    schedule.Name = string.Empty;
                    schedule.CategoryId = metricScheduleCategoryId;
                }

                // if the schedule was a unique schedule (configured in the Metric UI, set the schedule's ical content to the schedule builder UI's value
                if ( scheduleSelectionType == ScheduleSelectionType.Unique )
                {
                    schedule.iCalendarContent = sbSchedule.iCalendarContent;
                }

                if ( !schedule.HasSchedule() && scheduleSelectionType == ScheduleSelectionType.Unique )
                {
                    // don't save as a unique schedule if the schedule doesn't do anything
                    schedule = null;
                }
                else
                {
                    if ( schedule.Id == 0 )
                    {
                        scheduleService.Add( schedule );

                        // save to make sure we have a scheduleId
                        rockContext.SaveChanges();
                    }
                }
开发者ID:NewSpring,项目名称:Rock,代码行数:67,代码来源:MetricDetail.ascx.cs

示例11: btnDelete_Click

        /// <summary>
        /// Handles the Click event of the btnDelete control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnDelete_Click( object sender, EventArgs e )
        {
            int? categoryId = null;

            var rockContext = new RockContext();
            var service = new ScheduleService( rockContext );
            var item = service.Get( int.Parse( hfScheduleId.Value ) );

            if ( item != null )
            {
                string errorMessage;
                if ( !service.CanDelete( item, out errorMessage ) )
                {
                    ShowReadonlyDetails( item );
                    mdDeleteWarning.Show( errorMessage, ModalAlertType.Information );
                }
                else
                {
                    categoryId = item.CategoryId;

                    service.Delete( item );
                    rockContext.SaveChanges();

                    // reload page, selecting the deleted data view's parent
                    var qryParams = new Dictionary<string, string>();
                    if ( categoryId != null )
                    {
                        qryParams["CategoryId"] = categoryId.ToString();
                    }

                    NavigateToPage( RockPage.Guid, qryParams );
                }
            }
        }
开发者ID:Higherbound,项目名称:Higherbound-2016-website-upgrades,代码行数:39,代码来源:ScheduleDetail.ascx.cs

示例12: ShowDetails

        /// <summary>
        /// Binds the group members grid.
        /// </summary>
        protected void ShowDetails()
        {
            bool existingOccurrence = _occurrence != null;

            if ( !existingOccurrence && !_allowAdd )
            {
                nbNotice.Heading = "No Occurrences";
                nbNotice.Text = "<p>There are currently not any active occurrences for selected group to take attendance for.</p>";
                nbNotice.NotificationBoxType = NotificationBoxType.Warning;
                nbNotice.Visible = true;

                pnlDetails.Visible = false;
            }
            else
            {
                if ( existingOccurrence )
                {
                    lOccurrenceDate.Visible = _occurrence.ScheduleId.HasValue;
                    lOccurrenceDate.Text = _occurrence.Date.ToShortDateString();

                    dpOccurrenceDate.Visible = !_occurrence.ScheduleId.HasValue;
                    dpOccurrenceDate.SelectedDate = _occurrence.Date;

                    if ( _occurrence.LocationId.HasValue )
                    {
                        lLocation.Visible = true;
                        lLocation.Text = new LocationService( _rockContext ).GetPath( _occurrence.LocationId.Value );
                    }
                    else
                    {
                        lLocation.Visible = false;
                    }
                    ddlLocation.Visible = false;

                    lSchedule.Visible = !string.IsNullOrWhiteSpace( _occurrence.ScheduleName );
                    lSchedule.Text = _occurrence.ScheduleName;
                    ddlSchedule.Visible = false;
                }
                else
                {
                    lOccurrenceDate.Visible = false;
                    dpOccurrenceDate.Visible = true;
                    dpOccurrenceDate.SelectedDate = RockDateTime.Today;

                    int? locationId = PageParameter( "LocationId" ).AsIntegerOrNull();
                    if ( locationId.HasValue )
                    {
                        lLocation.Visible = true;
                        lLocation.Text = new LocationService( _rockContext ).GetPath( locationId.Value );
                        ddlLocation.Visible = false;

                        Schedule schedule = null;
                        int? scheduleId = PageParameter( "ScheduleId" ).AsIntegerOrNull();
                        if ( scheduleId.HasValue )
                        {
                            schedule = new ScheduleService( _rockContext ).Get( scheduleId.Value );
                        }

                        if ( schedule != null )
                        {
                            lSchedule.Visible = true;
                            lSchedule.Text = schedule.Name;
                            ddlSchedule.Visible = false;
                        }
                        else
                        {
                            BindSchedules( locationId.Value );
                            lSchedule.Visible = false;
                            ddlSchedule.Visible = ddlSchedule.Items.Count > 1;
                        }
                    }
                    else
                    {
                        lLocation.Visible = false;
                        ddlLocation.Visible = ddlLocation.Items.Count > 1;

                        lSchedule.Visible = false;
                        ddlSchedule.Visible = ddlSchedule.Items.Count > 1;
                    }
                }

                lMembers.Text = _group.GroupType.GroupMemberTerm.Pluralize();
                lPendingMembers.Text = "Pending " + lMembers.Text;

                List<int> attendedIds = new List<int>();

                // Load the attendance for the selected occurrence
                if ( existingOccurrence )
                {
                    cbDidNotMeet.Checked = _occurrence.DidNotOccur;

                    // Get the list of people who attended
                    attendedIds = new ScheduleService( _rockContext ).GetAttendance( _group, _occurrence )
                        .Where( a => a.DidAttend.HasValue && a.DidAttend.Value )
                        .Select( a => a.PersonAlias.PersonId )
                        .Distinct()
                        .ToList();
//.........这里部分代码省略.........
开发者ID:NewSpring,项目名称:Rock,代码行数:101,代码来源:GroupAttendanceDetail.ascx.cs

示例13: rFilter_DisplayFilterValue

        /// <summary>
        /// Rs the filter_ display filter value.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        protected void rFilter_DisplayFilterValue( object sender, GridFilter.DisplayFilterValueArgs e )
        {
            var rockContext = new RockContext();
            switch ( e.Key )
            {
                case "Date Range":
                    e.Value = DateRangePicker.FormatDelimitedValues( e.Value );
                    break;

                case "Person":
                    int? personId = e.Value.AsIntegerOrNull();
                    e.Value = null;
                    if ( personId.HasValue )
                    {
                        var person = new PersonService( rockContext ).Get( personId.Value );
                        if ( person != null )
                        {
                            e.Value = person.ToString();
                        }
                    }
                    break;

                case "Group":
                    int? groupId = e.Value.AsIntegerOrNull();
                    e.Value = null;
                    if ( groupId.HasValue )
                    {
                        var group = new GroupService( rockContext ).Get( groupId.Value );
                        if ( group != null )
                        {
                            e.Value = group.ToString();
                        }
                    }
                    break;

                case "Schedule":
                    int? scheduleId = e.Value.AsIntegerOrNull();
                    e.Value = null;
                    if ( scheduleId.HasValue )
                    {
                        var schedule = new ScheduleService( rockContext ).Get( scheduleId.Value );
                        if ( schedule != null )
                        {
                            e.Value = schedule.Name;
                        }
                    }
                    break;

                case "Attended":
                    if ( e.Value == "1" )
                    {
                        e.Value = "Did Attend";
                    }
                    else if ( e.Value == "0" )
                    {
                        e.Value = "Did Not Attend";
                    }
                    else
                    {
                        e.Value = null;
                    }

                    break;

                default:
                    e.Value = null;
                    break;
            }
        }
开发者ID:SparkDevNetwork,项目名称:Rock,代码行数:75,代码来源:AttendanceHistoryList.ascx.cs

示例14: btnSave_Click

        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click( object sender, EventArgs e )
        {
            using ( new UnitOfWorkScope() )
            {
                GroupLocationService groupLocationService = new GroupLocationService();
                ScheduleService scheduleService = new ScheduleService();

                RockTransactionScope.WrapTransaction( () =>
                {
                    var gridViewRows = gGroupLocationSchedule.Rows;
                    foreach ( GridViewRow row in gridViewRows.OfType<GridViewRow>() )
                    {
                        int groupLocationId = int.Parse( gGroupLocationSchedule.DataKeys[row.RowIndex].Value as string );
                        GroupLocation groupLocation = groupLocationService.Get( groupLocationId );
                        if ( groupLocation != null )
                        {
                            foreach ( var fieldCell in row.Cells.OfType<DataControlFieldCell>() )
                            {
                                CheckBoxEditableField checkBoxTemplateField = fieldCell.ContainingField as CheckBoxEditableField;
                                if ( checkBoxTemplateField != null )
                                {
                                    CheckBox checkBox = fieldCell.Controls[0] as CheckBox;
                                    string dataField = ( fieldCell.ContainingField as CheckBoxEditableField ).DataField;
                                    int scheduleId = int.Parse( dataField.Replace( "scheduleField_", string.Empty ) );

                                    // update GroupLocationSchedule depending on if the Schedule is Checked or not
                                    if ( checkBox.Checked )
                                    {
                                        // This schedule is selected, so if GroupLocationSchedule doesn't already have this schedule, add it
                                        if ( !groupLocation.Schedules.Any( a => a.Id == scheduleId ) )
                                        {
                                            var schedule = scheduleService.Get( scheduleId );
                                            groupLocation.Schedules.Add( schedule );
                                        }
                                    }
                                    else
                                    {
                                        // This schedule is not selected, so if GroupLocationSchedule has this schedule, delete it
                                        if ( groupLocation.Schedules.Any( a => a.Id == scheduleId ) )
                                        {
                                            groupLocation.Schedules.Remove( groupLocation.Schedules.FirstOrDefault( a => a.Id == scheduleId ) );
                                        }
                                    }
                                }
                            }

                            groupLocationService.Save( groupLocation, this.CurrentPersonId );
                        }
                    }

                } );
            }

            NavigateToParentPage();
        }
开发者ID:pkdevbox,项目名称:Rock,代码行数:60,代码来源:CheckinScheduleBuilder.ascx.cs

示例15: btnSave_Click


//.........这里部分代码省略.........
                metric.DataViewId = null;
            }

            var scheduleSelectionType = rblScheduleSelect.SelectedValueAsEnum<ScheduleSelectionType>();
            if ( scheduleSelectionType == ScheduleSelectionType.NamedSchedule )
            {
                metric.ScheduleId = ddlSchedule.SelectedValueAsId();
            }
            else
            {
                metric.ScheduleId = hfUniqueScheduleId.ValueAsInt();
            }

            if ( !Page.IsValid )
            {
                return;
            }

            if ( !metric.IsValid )
            {
                // Controls will render the error messages
                return;
            }

            if ( !cpMetricCategories.SelectedValuesAsInt().Any() )
            {
                cpMetricCategories.ShowErrorMessage( "Must select at least one category" );
                return;
            }

            // do a WrapTransaction since we are doing multiple SaveChanges()
            rockContext.WrapTransaction( () =>
            {
                var scheduleService = new ScheduleService( rockContext );
                var schedule = scheduleService.Get( metric.ScheduleId ?? 0 );
                int metricScheduleCategoryId = new CategoryService( rockContext ).Get( Rock.SystemGuid.Category.SCHEDULE_METRICS.AsGuid() ).Id;
                if ( schedule == null )
                {
                    schedule = new Schedule();

                    // make it an "Unnamed" metrics schedule
                    schedule.Name = string.Empty;
                    schedule.CategoryId = metricScheduleCategoryId;
                }

                // if the schedule was a unique schedule (configured in the Metric UI, set the schedule's ical content to the schedule builder UI's value
                if ( scheduleSelectionType == ScheduleSelectionType.Unique )
                {
                    schedule.iCalendarContent = sbSchedule.iCalendarContent;
                }

                if ( !schedule.HasSchedule() && scheduleSelectionType == ScheduleSelectionType.Unique )
                {
                    // don't save as a unique schedule if the schedule doesn't do anything
                    schedule = null;
                }
                else
                {
                    if ( schedule.Id == 0 )
                    {
                        scheduleService.Add( schedule );

                        // save to make sure we have a scheduleId
                        rockContext.SaveChanges();
                    }
                }
开发者ID:NewPointe,项目名称:Rockit,代码行数:67,代码来源:MetricDetail.ascx.cs


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