Exemplo n.º 1
0
        /// <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)
        {
            RockContext rockContext = new RockContext();
            var         groupMemberScheduleTemplateService = new GroupMemberScheduleTemplateService(rockContext);

            GroupMemberScheduleTemplate groupMemberScheduleTemplate;

            int groupMemberScheduleTemplateId = hfGroupMemberScheduleTemplateId.Value.AsInteger();

            if (groupMemberScheduleTemplateId == 0)
            {
                groupMemberScheduleTemplate = new GroupMemberScheduleTemplate();
                groupMemberScheduleTemplateService.Add(groupMemberScheduleTemplate);
            }
            else
            {
                groupMemberScheduleTemplate = groupMemberScheduleTemplateService.Get(groupMemberScheduleTemplateId);
            }

            groupMemberScheduleTemplate.Name = tbName.Text;

            if (groupMemberScheduleTemplate.Schedule == null)
            {
                groupMemberScheduleTemplate.Schedule = new Schedule();
            }

            groupMemberScheduleTemplate.Schedule.iCalendarContent = sbSchedule.iCalendarContent;

            rockContext.SaveChanges();

            NavigateToParentPage();
        }
        /// <summary>
        /// Handles the DeleteClick event of the gList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gList_DeleteClick(object sender, Rock.Web.UI.Controls.RowEventArgs e)
        {
            var rockContext = new RockContext();
            GroupMemberScheduleTemplateService groupMemberScheduleTemplateService = new GroupMemberScheduleTemplateService(rockContext);
            GroupMemberScheduleTemplate        groupMemberScheduleTemplate        = groupMemberScheduleTemplateService.Get(e.RowKeyId);

            if (groupMemberScheduleTemplate != null)
            {
                string errorMessage;
                if (!groupMemberScheduleTemplateService.CanDelete(groupMemberScheduleTemplate, out errorMessage))
                {
                    mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                groupMemberScheduleTemplateService.Delete(groupMemberScheduleTemplate);
                rockContext.SaveChanges();
            }

            BindGrid();
        }