/// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindLinkagesGrid()
        {
            int?instanceId = this.RegistrationInstanceId;

            if (!instanceId.HasValue)
            {
                return;
            }

            var groupCol = gLinkages.Columns[2] as HyperLinkField;

            var groupDetailUrl = LinkedPageUrl(AttributeKey.GroupDetailPage);

            if (!string.IsNullOrWhiteSpace(groupDetailUrl))
            {
                groupCol.DataNavigateUrlFormatString = groupDetailUrl + "?GroupID={0}";
            }

            using (var rockContext = new RockContext())
            {
                var qry = new EventItemOccurrenceGroupMapService(rockContext)
                          .Queryable("EventItemOccurrence.EventItem.EventCalendarItems.EventCalendar,EventItemOccurrence.ContentChannelItems.ContentChannelItem,Group")
                          .AsNoTracking()
                          .Where(r => r.RegistrationInstanceId == instanceId.Value);

                List <int> campusIds = cblCampus.SelectedValuesAsInt;
                if (campusIds.Any())
                {
                    qry = qry
                          .Where(l =>
                                 l.EventItemOccurrence != null &&
                                 (
                                     !l.EventItemOccurrence.CampusId.HasValue ||
                                     campusIds.Contains(l.EventItemOccurrence.CampusId.Value)
                                 ));
                }

                IOrderedQueryable <EventItemOccurrenceGroupMap> orderedQry = null;
                SortProperty sortProperty = gLinkages.SortProperty;
                if (sortProperty != null)
                {
                    orderedQry = qry.Sort(sortProperty);
                }
                else
                {
                    orderedQry = qry.OrderByDescending(r => r.CreatedDateTime);
                }

                gLinkages.SetLinqDataSource(orderedQry);
                gLinkages.DataBind();
            }
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        public void ShowDetail(int linkageId)
        {
            pnlDetails.Visible = true;

            EventItemOccurrenceGroupMap linkage = null;

            var rockContext = new RockContext();

            if (!linkageId.Equals(0))
            {
                linkage           = new EventItemOccurrenceGroupMapService(rockContext).Get(linkageId);
                lActionTitle.Text = ActionTitle.Edit("Linkage").FormatAsHtmlTitle();
            }

            if (linkage == null)
            {
                linkage = new EventItemOccurrenceGroupMap {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add("Linkage").FormatAsHtmlTitle();
            }

            hfLinkageId.Value = linkage.Id.ToString();

            if (linkage.EventItemOccurrence != null)
            {
                hfLinkageEventItemOccurrenceId.Value       = linkage.EventItemOccurrence.Id.ToString();
                lLinkageEventItemOccurrence.Text           = linkage.EventItemOccurrence.ToString();
                lbLinkageEventItemOccurrenceAdd.Visible    = false;
                lbLinkageEventItemOccurrenceRemove.Visible = true;
            }
            else
            {
                hfLinkageEventItemOccurrenceId.Value       = string.Empty;
                lLinkageEventItemOccurrence.Text           = string.Empty;
                lbLinkageEventItemOccurrenceAdd.Visible    = true;
                lbLinkageEventItemOccurrenceRemove.Visible = false;
            }

            gpLinkageGroup.SetValue(linkage.Group);
            gpLinkageGroup_SelectItem(null, null);

            tbLinkagePublicName.Text = linkage.PublicName;
            tbLinkageUrlSlug.Text    = linkage.UrlSlug;
        }
Beispiel #3
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        public void ShowDetail( int linkageId )
        {
            pnlDetails.Visible = true;

            EventItemOccurrenceGroupMap linkage = null;

            var rockContext = new RockContext();

            if ( !linkageId.Equals( 0 ) )
            {
                linkage = new EventItemOccurrenceGroupMapService( rockContext ).Get( linkageId );
                lActionTitle.Text = ActionTitle.Edit( "Linkage" ).FormatAsHtmlTitle();
            }

            if ( linkage == null )
            {
                linkage = new EventItemOccurrenceGroupMap { Id = 0 };
                lActionTitle.Text = ActionTitle.Add( "Linkage" ).FormatAsHtmlTitle();
            }

            hfLinkageId.Value = linkage.Id.ToString();

            if ( linkage.EventItemOccurrence != null )
            {
                hfLinkageEventItemOccurrenceId.Value = linkage.EventItemOccurrence.Id.ToString();
                lLinkageEventItemOccurrence.Text = linkage.EventItemOccurrence.ToString();
                lbLinkageEventItemOccurrenceAdd.Visible = false;
                lbLinkageEventItemOccurrenceRemove.Visible = true;
            }
            else
            {
                hfLinkageEventItemOccurrenceId.Value = string.Empty;
                lLinkageEventItemOccurrence.Text = string.Empty;
                lbLinkageEventItemOccurrenceAdd.Visible = true;
                lbLinkageEventItemOccurrenceRemove.Visible = false;
            }

            gpLinkageGroup.SetValue( linkage.Group );

            tbLinkagePublicName.Text = linkage.PublicName;
            tbLinkageUrlSlug.Text = linkage.UrlSlug;
        }
        /// <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 (var rockContext = new RockContext())
            {
                var service = new EventItemOccurrenceGroupMapService(rockContext);

                EventItemOccurrenceGroupMap linkage = null;

                int?linkageId = hfLinkageId.Value.AsIntegerOrNull();
                if (linkageId.HasValue)
                {
                    linkage = service.Get(linkageId.Value);
                }

                if (linkage == null)
                {
                    linkage = new EventItemOccurrenceGroupMap();
                    linkage.RegistrationInstanceId = PageParameter("RegistrationInstanceId").AsInteger();
                    service.Add(linkage);
                }

                linkage.EventItemOccurrenceId = hfLinkageEventItemOccurrenceId.Value.AsIntegerOrNull();
                linkage.GroupId    = gpLinkageGroup.SelectedValueAsInt();
                linkage.PublicName = tbLinkagePublicName.Text;
                linkage.UrlSlug    = tbLinkageUrlSlug.Text;

                if (!Page.IsValid || !linkage.IsValid)
                {
                    return;
                }

                rockContext.SaveChanges();
            }

            var qryParams = new Dictionary <string, string>();

            qryParams.Add("RegistrationInstanceId", PageParameter("RegistrationInstanceId"));
            qryParams.Add("Tab", "4");
            NavigateToParentPage(qryParams);
        }
        protected void cvUrlSlug_ServerValidate(object source, ServerValidateEventArgs args)
        {
            var urlSlug = args.Value;

            if (urlSlug.IsNullOrWhiteSpace())
            {
                return;
            }

            using (var rockContext = new RockContext())
            {
                var eventMapingService = new EventItemOccurrenceGroupMapService(rockContext);
                var linkageId          = hfLinkageId.Value.AsIntegerOrNull();

                var validationQuery = eventMapingService.Queryable().AsNoTracking().Where(m => m.UrlSlug == urlSlug);
                if (linkageId != null)
                {
                    validationQuery = validationQuery.Where(m => m.Id != linkageId.Value);
                }
                args.IsValid = !validationQuery.Any();
            }
        }
        /// <summary>
        /// Handles the Delete event of the gLinkages 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 gLinkages_Delete(object sender, RowEventArgs e)
        {
            using (var rockContext = new RockContext())
            {
                var campusEventItemService = new EventItemOccurrenceGroupMapService(rockContext);
                var campusEventItem        = campusEventItemService.Get(e.RowKeyId);
                if (campusEventItem != null)
                {
                    string errorMessage;
                    if (!campusEventItemService.CanDelete(campusEventItem, out errorMessage))
                    {
                        mdLinkagesGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }

                    campusEventItemService.Delete(campusEventItem);
                    rockContext.SaveChanges();
                }
            }

            BindLinkagesGrid();
        }
Beispiel #7
0
        /// <summary>
        /// Handles the Delete event of the gLinkages 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 gLinkages_Delete( object sender, RowEventArgs e )
        {
            using ( var rockContext = new RockContext() )
            {
                var campusEventItemService = new EventItemOccurrenceGroupMapService( rockContext );
                var campusEventItem = campusEventItemService.Get( e.RowKeyId );
                if ( campusEventItem != null )
                {
                    string errorMessage;
                    if ( !campusEventItemService.CanDelete( campusEventItem, out errorMessage ) )
                    {
                        mdLinkagesGridWarning.Show( errorMessage, ModalAlertType.Information );
                        return;
                    }

                    campusEventItemService.Delete( campusEventItem );
                    rockContext.SaveChanges();
                }
            }

            BindLinkagesGrid();
        }
Beispiel #8
0
        /// <summary>
        /// Binds the registrations grid.
        /// </summary>
        private void BindLinkagesGrid()
        {
            int? instanceId = hfRegistrationInstanceId.Value.AsIntegerOrNull();
            if ( instanceId.HasValue )
            {
                var groupCol = gLinkages.Columns[2] as HyperLinkField;
                groupCol.DataNavigateUrlFormatString = LinkedPageUrl( "GroupDetailPage" ) + "?GroupID={0}";

                using ( var rockContext = new RockContext() )
                {
                    var qry = new EventItemOccurrenceGroupMapService( rockContext )
                        .Queryable( "EventItemOccurrence.EventItem.EventCalendarItems.EventCalendar,EventItemOccurrence.ContentChannelItems.ContentChannelItem,Group" )
                        .AsNoTracking()
                        .Where( r => r.RegistrationInstanceId == instanceId.Value );

                    List<int> campusIds = cblCampus.SelectedValuesAsInt;
                    if ( campusIds.Any() )
                    {
                        qry = qry
                            .Where( l =>
                                l.EventItemOccurrence != null &&
                                (
                                    !l.EventItemOccurrence.CampusId.HasValue ||
                                    campusIds.Contains( l.EventItemOccurrence.CampusId.Value )
                                ) );
                    }

                    IOrderedQueryable<EventItemOccurrenceGroupMap> orderedQry = null;
                    SortProperty sortProperty = gLinkages.SortProperty;
                    if ( sortProperty != null )
                    {
                        orderedQry = qry.Sort( sortProperty );
                    }
                    else
                    {
                        orderedQry = qry.OrderByDescending( r => r.CreatedDateTime );
                    }

                    gLinkages.SetLinqDataSource( orderedQry );
                    gLinkages.DataBind();
                }
            }
        }
        protected void lbRegister_Click(object sender, EventArgs e)
        {
            var rockContext = new RockContext();

            // get the person who was passed in for the registration registrar
            Person person = null;

            Guid personGuid = Guid.Empty;

            if (Request["PersonGuid"] != null)
            {
                personGuid = Request["PersonGuid"].AsGuid();

                person = new PersonService(_rockContext).Get(personGuid);
            }

            if (person == null)
            {
                lErrors.Text = "<div class='alert alert-warning'>Invalid person guid was passed.</div>";
                return;
            }

            // get event item
            int eventItemOccurrenceId = hfSelectedEventId.Value.AsInteger();

            // find registration
            var eventGroup = new EventItemOccurrenceGroupMapService(_rockContext).Queryable()
                             .Where(m => m.EventItemOccurrenceId == eventItemOccurrenceId)
                             .Select(m => m.Group)
                             .FirstOrDefault();

            var registrationLinkages = eventGroup.Linkages.ToList();


            if (registrationLinkages.Count() == 0)
            {
                lErrors.Text = "<div class='alert alert-warning'>No registration instances exists for this event.</div>";
                return;
            }

            EventItemOccurrenceGroupMap registrationLinkage = registrationLinkages.First();

            // create new registration
            var registrationService = new RegistrationService(rockContext);

            Registration registration = new Registration();

            registrationService.Add(registration);

            registration.RegistrationInstanceId = registrationLinkage.RegistrationInstanceId.Value;
            registration.ConfirmationEmail      = ebEmailReminder.Text;
            registration.PersonAliasId          = person.PrimaryAliasId;
            registration.FirstName   = person.NickName;
            registration.LastName    = person.LastName;
            registration.IsTemporary = true;

            // add registrants
            foreach (int registrantId in cblRegistrants.SelectedValuesAsInt)
            {
                RegistrationRegistrant registrant = new RegistrationRegistrant();
                registrant.PersonAliasId = registrantId;
                registration.Registrants.Add(registrant);
            }

            rockContext.SaveChanges();

            // redirect to registration page
            var queryParams = new Dictionary <string, string>();

            queryParams.Add("RegistrationInstanceId", registrationLinkage.RegistrationInstanceId.ToString());
            queryParams.Add("RegistrationId", registration.Id.ToString());
            queryParams.Add("StartAtBeginning", GetAttributeValue("StartRegistrationAtBeginning"));

            if (!string.IsNullOrWhiteSpace(registrationLinkage.UrlSlug))
            {
                queryParams.Add("Slug", registrationLinkage.UrlSlug);
            }

            if (registrationLinkage.Group != null)
            {
                queryParams.Add("GroupId", registrationLinkage.GroupId.ToString());
            }

            NavigateToLinkedPage("RegistrationPage", queryParams);
        }
Beispiel #10
0
        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var rockContext = new RockContext();

            var groupMemberService            = new GroupMemberService(rockContext);
            var groupService                  = new GroupService(rockContext);
            var groupTypeService              = new GroupTypeService(rockContext);
            var attributeService              = new AttributeService(rockContext);
            var attributeValueService         = new AttributeValueService(rockContext);
            var personService                 = new PersonService(rockContext);
            var personAliasService            = new PersonAliasService(rockContext);
            var entityTypeService             = new EntityTypeService(rockContext);
            var registrationRegistrantService = new RegistrationRegistrantService(rockContext);
            var eiogmService                  = new EventItemOccurrenceGroupMapService(rockContext);
            var groupLocationService          = new GroupLocationService(rockContext);
            var locationService               = new LocationService(rockContext);
            var signatureDocumentServce       = new SignatureDocumentService(rockContext);
            var phoneNumberService            = new PhoneNumberService(rockContext);

            int[] signatureDocumentIds = { };
            if (!string.IsNullOrWhiteSpace(GetAttributeValue("SignatureDocumentTemplates")))
            {
                signatureDocumentIds = Array.ConvertAll(GetAttributeValue("SignatureDocumentTemplates").Split(','), int.Parse);
            }
            Guid bbGroup = GetAttributeValue("Group").AsGuid();
            var  group   = new GroupService(rockContext).Get(bbGroup);

            if (group.Name.Contains("Week 2"))
            {
                cmpCampus.Visible = true;
            }

            Guid hsmGroupTypeGuid = GetAttributeValue("MSMGroupType").AsGuid();
            int? hsmGroupTypeId   = groupTypeService.Queryable().Where(gt => gt.Guid == hsmGroupTypeGuid).Select(gt => gt.Id).FirstOrDefault();

            int entityTypeId = entityTypeService.Queryable().Where(et => et.Name == typeof(Rock.Model.Group).FullName).FirstOrDefault().Id;

            var registrationTemplateIds = eiogmService.Queryable().Where(r => r.GroupId == group.Id).Select(m => m.RegistrationInstance.RegistrationTemplateId.ToString()).ToList();

            hlGroup.NavigateUrl = "/group/" + group.Id;

            var attributeIds = attributeService.Queryable()
                               .Where(a => (a.EntityTypeQualifierColumn == "GroupId" && a.EntityTypeQualifierValue == group.Id.ToString()) ||
                                      (a.EntityTypeQualifierColumn == "GroupTypeId" && a.EntityTypeQualifierValue == group.GroupTypeId.ToString()) ||
                                      (a.EntityTypeQualifierColumn == "RegistrationTemplateId" && registrationTemplateIds.Contains(a.EntityTypeQualifierValue)))
                               .Select(a => a.Id).ToList();

            var gmTmpqry = groupMemberService.Queryable()
                           .Where(gm => (gm.GroupId == group.Id));

            var qry = gmTmpqry
                      .GroupJoin(registrationRegistrantService.Queryable(),
                                 obj => obj.Id,
                                 rr => rr.GroupMemberId,
                                 (obj, rr) => new { GroupMember = obj, Person = obj.Person, RegistrationRegistrant = rr })
                      .GroupJoin(attributeValueService.Queryable(),
                                 obj => new { PersonId = (int?)obj.Person.Id, AttributeId = 739 },
                                 av => new { PersonId = av.EntityId, av.AttributeId },
                                 (obj, av) => new { GroupMember = obj.GroupMember, Person = obj.Person, RegistrationRegistrant = obj.RegistrationRegistrant, School = av.Select(s => s.Value).FirstOrDefault() })
                      .GroupJoin(attributeValueService.Queryable(),
                                 obj => obj.GroupMember.Id,
                                 av => av.EntityId.Value,
                                 (obj, avs) => new { GroupMember = obj.GroupMember, Person = obj.Person, RegistrationRegistrant = obj.RegistrationRegistrant, GroupMemberAttributeValues = avs.Where(av => attributeIds.Contains(av.AttributeId)), School = obj.School /*, Location = obj.Location */ })
                      .GroupJoin(attributeValueService.Queryable(),
                                 obj => obj.RegistrationRegistrant.FirstOrDefault().Id,
                                 av => av.EntityId.Value,
                                 (obj, avs) => new { GroupMember = obj.GroupMember, Person = obj.Person, RegistrationRegistrant = obj.RegistrationRegistrant, GroupMemberAttributeValues = obj.GroupMemberAttributeValues, RegistrationAttributeValues = avs.Where(av => attributeIds.Contains(av.AttributeId)), School = obj.School /*, Location = obj.Location */ });

            var qry2 = gmTmpqry
                       .GroupJoin(
                groupMemberService.Queryable()
                .Join(groupService.Queryable(),
                      gm => new { Id = gm.GroupId, GroupTypeId = 10 },
                      g => new { g.Id, g.GroupTypeId },
                      (gm, g) => new { GroupMember = gm, Group = g })
                .Join(groupLocationService.Queryable(),
                      obj => new { GroupId = obj.Group.Id, GroupLocationTypeValueId = (int?)19 },
                      gl => new { gl.GroupId, gl.GroupLocationTypeValueId },
                      (g, gl) => new { GroupMember = g.GroupMember, GroupLocation = gl })
                .Join(locationService.Queryable(),
                      obj => obj.GroupLocation.LocationId,
                      l => l.Id,
                      (obj, l) => new { GroupMember = obj.GroupMember, Location = l }),
                gm => gm.PersonId,
                glgm => glgm.GroupMember.PersonId,
                (obj, l) => new { GroupMember = obj, Location = l.Select(loc => loc.Location).FirstOrDefault() }
                )
                       .GroupJoin(signatureDocumentServce.Queryable()
                                  .Join(personAliasService.Queryable(),
                                        sd => sd.AppliesToPersonAliasId,
                                        pa => pa.Id,
                                        (sd, pa) => new { SignatureDocument = sd, Alias = pa }),
                                  obj => obj.GroupMember.PersonId,
                                  sd => sd.Alias.PersonId,
                                  (obj, sds) => new { GroupMember = obj.GroupMember, Location = obj.Location, SignatureDocuments = sds })
                       .GroupJoin(phoneNumberService.Queryable(),
                                  obj => obj.GroupMember.PersonId,
                                  p => p.PersonId,
                                  (obj, pn) => new { GroupMember = obj.GroupMember, Location = obj.Location, SignatureDocuments = obj.SignatureDocuments, PhoneNumbers = pn });


            if (!String.IsNullOrWhiteSpace(GetUserPreference(string.Format("{0}PersonName", keyPrefix))))
            {
                string personName = GetUserPreference(string.Format("{0}PersonName", keyPrefix)).ToLower();
                qry = qry.ToList().Where(q => q.GroupMember.Person.FullName.ToLower().Contains(personName)).AsQueryable();
            }
            decimal?lowerVal = GetUserPreference(string.Format("{0}BalanceOwedLower", keyPrefix)).AsDecimalOrNull();
            decimal?upperVal = GetUserPreference(string.Format("{0}BalanceOwedUpper", keyPrefix)).AsDecimalOrNull();

            if (lowerVal != null && upperVal != null)
            {
                qry = qry.ToList().Where(q => q.RegistrationRegistrant.Select(rr => rr.Registration.BalanceDue).FirstOrDefault() >= lowerVal && q.RegistrationRegistrant.Select(rr => rr.Registration.BalanceDue).FirstOrDefault() <= upperVal).AsQueryable();
            }
            else if (lowerVal != null)
            {
                qry = qry.ToList().Where(q => q.RegistrationRegistrant.Select(rr => rr.Registration.BalanceDue).FirstOrDefault() >= lowerVal).AsQueryable();
            }
            else if (upperVal != null)
            {
                qry = qry.ToList().Where(q => q.RegistrationRegistrant.Select(rr => rr.Registration.BalanceDue).FirstOrDefault() <= upperVal).AsQueryable();
            }
            else if (!string.IsNullOrEmpty(cmpCampus.SelectedValue))
            {
                if (group.Name.Contains("Week 2"))
                {
                    qry = qry.ToList().Where(q => q.RegistrationAttributeValues.Where(ra => ra.AttributeKey == "Whichcampusdoyouwanttodepartforcampfromandroomwith" && ra.Value == cmpCampus.SelectedValue).Any()).AsQueryable();
                }
            }

            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var tmp  = qry.ToList();
            var tmp2 = qry2.ToList();

            lStats.Text = "Query Runtime: " + stopwatch.Elapsed;
            stopwatch.Reset();

            stopwatch.Start();

            var newQry = tmp.Select(g => new
            {
                Id                    = g.GroupMember.Id,
                RegisteredBy          = new ModelValue <Person>(g.RegistrationRegistrant.Select(rr => rr.Registration.PersonAlias.Person).FirstOrDefault()),
                Registrant            = new ModelValue <Person>(g.Person),
                Age                   = g.Person.Age,
                GraduationYear        = g.Person.GraduationYear,
                RegistrationId        = g.RegistrationRegistrant.Select(rr => rr.RegistrationId).FirstOrDefault(),
                Group                 = new ModelValue <Rock.Model.Group>((Rock.Model.Group)g.GroupMember.Group),
                DOB                   = g.Person.BirthDate.HasValue ? g.Person.BirthDate.Value.ToShortDateString() : "",
                Address               = new ModelValue <Rock.Model.Location>((Rock.Model.Location)tmp2.Where(gm => gm.GroupMember.Id == g.GroupMember.Id).Select(gm => gm.Location).FirstOrDefault()),
                Email                 = g.Person.Email,
                Gender                = g.Person.Gender,         // (B & B Registration)
                GraduationYearProfile = g.Person.GraduationYear, // (Person Profile)
                HomePhone             = tmp2.Where(gm => gm.GroupMember.Id == g.GroupMember.Id).SelectMany(gm => gm.PhoneNumbers).Where(pn => pn.NumberTypeValue.Guid == Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME.AsGuid()).Select(pn => pn.NumberFormatted).FirstOrDefault(),
                CellPhone             = tmp2.Where(gm => gm.GroupMember.Id == g.GroupMember.Id).SelectMany(gm => gm.PhoneNumbers).Where(pn => pn.NumberTypeValue.Guid == Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE.AsGuid()).Select(pn => pn.NumberFormatted).FirstOrDefault(),
                GroupMemberData       = new Func <GroupMemberAttributes>(() =>
                {
                    GroupMemberAttributes gma = new GroupMemberAttributes(g.GroupMember, g.Person, g.GroupMemberAttributeValues);
                    return(gma);
                })(),
                RegistrantData = new Func <RegistrantAttributes>(() =>
                {
                    RegistrantAttributes row = new RegistrantAttributes(g.RegistrationRegistrant.FirstOrDefault(), g.RegistrationAttributeValues);
                    return(row);
                })(),
                School              = string.IsNullOrEmpty(g.School)?"":DefinedValueCache.Read(g.School.AsGuid()) != null?DefinedValueCache.Read(g.School.AsGuid()).Value:"",
                LegalRelease        = tmp2.Where(gm => gm.GroupMember.Id == g.GroupMember.Id).SelectMany(gm => gm.SignatureDocuments).OrderByDescending(sd => sd.SignatureDocument.CreatedDateTime).Where(sd => signatureDocumentIds.Contains(sd.SignatureDocument.SignatureDocumentTemplateId)).Select(sd => sd.SignatureDocument.SignatureDocumentTemplate.Name + " (" + sd.SignatureDocument.Status.ToString() + ")").FirstOrDefault(),
                Departure           = g.GroupMemberAttributeValues.Where(av => av.AttributeKey == "Departure").Select(av => av.Value).FirstOrDefault(),
                Campus              = group.Campus,                                                                                                        //
                Role                = group.ParentGroup.GroupType.Name.Contains("Serving") || group.Name.ToLower().Contains("leader")? "Leader":"Student", //
                MSMGroup            = String.Join(", ", groupMemberService.Queryable().Where(gm => gm.PersonId == g.GroupMember.PersonId && gm.Group.GroupTypeId == hsmGroupTypeId && gm.GroupMemberStatus == GroupMemberStatus.Active).Select(gm => gm.Group.Name).ToList()),
                Person              = g.Person,
                AddressStreet       = tmp2.Where(gm => gm.GroupMember.Id == g.GroupMember.Id).Select(gm => gm.Location != null?gm.Location.Street1:"").FirstOrDefault(),
                AddressCityStateZip = tmp2.Where(gm => gm.GroupMember.Id == g.GroupMember.Id).Select(gm => gm.Location != null ? gm.Location.City + ", " + gm.Location.State + " " + gm.Location.PostalCode : "").FirstOrDefault(),

                RegistrantName = g.Person.FullName,
            }).OrderBy(w => w.Registrant.Model.LastName).ToList().AsQueryable();

            lStats.Text += "<br />Object Build Runtime: " + stopwatch.Elapsed;

            stopwatch.Stop();
            gReport.GetRecipientMergeFields += GReport_GetRecipientMergeFields;
            var mergeFields = new List <String>();

            mergeFields.Add("Id");
            mergeFields.Add("RegisteredBy");
            mergeFields.Add("Group");
            mergeFields.Add("Registrant");
            mergeFields.Add("Age");
            mergeFields.Add("GraduationYear");
            mergeFields.Add("DOB");
            mergeFields.Add("Address");
            mergeFields.Add("Email");
            mergeFields.Add("Gender");
            mergeFields.Add("GraduationYearProfile");
            mergeFields.Add("HomePhone");
            mergeFields.Add("CellPhone");
            mergeFields.Add("GroupMemberData");
            mergeFields.Add("RegistrantData");
            mergeFields.Add("LegalRelease");
            mergeFields.Add("Departure");
            mergeFields.Add("Campus");
            mergeFields.Add("Role");
            mergeFields.Add("MSMGroup");
            gReport.CommunicateMergeFields = mergeFields;

            /*
             * if (!String.IsNullOrWhiteSpace(GetUserPreference(string.Format("{0}POA", keyPrefix))))
             * {
             *  string poa = GetUserPreference(string.Format("{0}POA", keyPrefix));
             *  if (poa == "[Blank]")
             *  {
             *      poa = "";
             *  }
             *  newQry = newQry.Where(q => q.GroupMemberData.POA == poa);
             * }
             */

            SortProperty sortProperty = gReport.SortProperty;

            if (sortProperty != null)
            {
                gReport.SetLinqDataSource(newQry.Sort(sortProperty));
            }
            else
            {
                gReport.SetLinqDataSource(newQry.OrderBy(p => p.Registrant.Model.LastName));
            }
            gReport.DataBind();
        }
Beispiel #11
0
        private void ShowNewLinkageDialog()
        {
            rieNewLinkage.ShowActive  = false;
            rieNewLinkage.ShowUrlSlug = true;

            ddlNewLinkageTemplate.Items.Clear();

            using (var rockContext = new RockContext())
            {
                // Find most recent mapping with same event, campus and copy some of it's registration instance values
                int EventItemId          = PageParameter("EventItemId").AsInteger();
                int?campusId             = ddlCampus.SelectedValueAsInt();
                var registrationInstance = new EventItemOccurrenceGroupMapService(rockContext)
                                           .Queryable()
                                           .Where(m =>
                                                  m.EventItemOccurrence != null &&
                                                  m.EventItemOccurrence.EventItemId == EventItemId &&
                                                  m.RegistrationInstance != null &&
                                                  (
                                                      (campusId.HasValue && (!m.EventItemOccurrence.CampusId.HasValue || m.EventItemOccurrence.CampusId.Value == campusId.Value)) ||
                                                      (!campusId.HasValue && !m.EventItemOccurrence.CampusId.HasValue)
                                                  )
                                                  )
                                           .ToList()
                                           .OrderByDescending(m => m.EventItemOccurrence.NextStartDateTime)
                                           .Select(m => m.RegistrationInstance)
                                           .FirstOrDefault();

                if (registrationInstance != null)
                {
                    LinkageState.RegistrationInstance           = new RegistrationInstance();
                    LinkageState.RegistrationInstance.AccountId = registrationInstance.AccountId;
                    LinkageState.RegistrationInstance.RegistrationTemplateId        = registrationInstance.RegistrationTemplateId;
                    LinkageState.RegistrationInstance.RegistrationTemplate          = new RegistrationTemplate();
                    LinkageState.RegistrationInstance.ContactPersonAliasId          = registrationInstance.ContactPersonAliasId;
                    LinkageState.RegistrationInstance.ContactPhone                  = registrationInstance.ContactPhone;
                    LinkageState.RegistrationInstance.ContactEmail                  = registrationInstance.ContactEmail;
                    LinkageState.RegistrationInstance.AdditionalReminderDetails     = registrationInstance.AdditionalReminderDetails;
                    LinkageState.RegistrationInstance.AdditionalConfirmationDetails = registrationInstance.AdditionalConfirmationDetails;
                    var registrationTemplate = new RegistrationTemplateService(rockContext).Get(registrationInstance.RegistrationTemplateId);
                    if (registrationTemplate != null)
                    {
                        LinkageState.RegistrationInstance.RegistrationTemplate.CopyPropertiesFrom(registrationTemplate);
                    }
                }

                foreach (var template in new RegistrationTemplateService(rockContext)
                         .Queryable().AsNoTracking().OrderBy(t => t.Name))
                {
                    if (template.IsAuthorized(Authorization.VIEW, CurrentPerson))
                    {
                        ListItem li = new ListItem(template.Name, template.Id.ToString());
                        ddlNewLinkageTemplate.Items.Add(li);
                        li.Selected = LinkageState.RegistrationInstance != null &&
                                      LinkageState.RegistrationInstance.RegistrationTemplateId == template.Id;
                    }
                }

                gpNewLinkageGroup.SetValue(LinkageState.Group);

                rieNewLinkage.SetValue(LinkageState.RegistrationInstance);
                rieNewLinkage.UrlSlug = LinkageState.UrlSlug;

                if (LinkageState.RegistrationInstance == null)
                {
                    var contactPersonAliasId = ppContact.PersonAliasId;
                    if (contactPersonAliasId.HasValue)
                    {
                        var personAlias = new PersonAliasService(rockContext).Get(contactPersonAliasId.Value);
                        if (personAlias != null)
                        {
                            rieNewLinkage.ContactPersonAlias = personAlias;
                        }
                    }

                    if (!string.IsNullOrWhiteSpace(pnPhone.Text))
                    {
                        rieNewLinkage.ContactPhone = pnPhone.Text;
                    }

                    if (!string.IsNullOrWhiteSpace(tbEmail.Text))
                    {
                        rieNewLinkage.ContactEmail = tbEmail.Text;
                    }

                    Guid?accountGuid = GetAttributeValue("DefaultAccount").AsGuidOrNull();
                    if (accountGuid.HasValue)
                    {
                        var account = new FinancialAccountService(rockContext).Get(accountGuid.Value);
                        rieNewLinkage.AccountId = account != null ? account.Id : 0;
                    }
                }
            }

            ShowDialog("EventItemNewLinkage", true);
        }
Beispiel #12
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 )
        {
            using ( var rockContext = new RockContext() )
            {
                var service = new EventItemOccurrenceGroupMapService( rockContext );

                EventItemOccurrenceGroupMap linkage = null;

                int? linkageId = hfLinkageId.Value.AsIntegerOrNull();
                if ( linkageId.HasValue )
                {
                    linkage = service.Get( linkageId.Value );
                }

                if ( linkage == null )
                {
                    linkage = new EventItemOccurrenceGroupMap();
                    linkage.RegistrationInstanceId = PageParameter( "RegistrationInstanceId" ).AsInteger();
                    service.Add( linkage );
                }

                linkage.EventItemOccurrenceId = hfLinkageEventItemOccurrenceId.Value.AsIntegerOrNull();
                linkage.GroupId = gpLinkageGroup.SelectedValueAsInt();
                linkage.PublicName = tbLinkagePublicName.Text;
                linkage.UrlSlug = tbLinkageUrlSlug.Text;

                if ( !Page.IsValid || !linkage.IsValid )
                {
                    return;
                }

                rockContext.SaveChanges();
            }

            var qryParams = new Dictionary<string, string>();
            qryParams.Add( "RegistrationInstanceId", PageParameter( "RegistrationInstanceId" ) );
            qryParams.Add( "Tab", "3" );
            NavigateToParentPage( qryParams );
        }
        protected void lbRegister_Click( object sender, EventArgs e )
        {
            var rockContext = new RockContext();

            // get the person who was passed in for the registration registar
            Person person = null;

            Guid personGuid = Guid.Empty;
            if ( Request["PersonGuid"] != null )
            {
                personGuid = Request["PersonGuid"].AsGuid();

                person = new PersonService( _rockContext ).Get( personGuid );
            }

            if ( person == null )
            {
                lErrors.Text = "<div class='alert alert-warning'>Invalid person guid was passed.</div>";
                return;
            }

            // get event item
            int eventItemOccurrenceId = hfSelectedEventId.Value.AsInteger();

            // find registration
            var eventGroup = new EventItemOccurrenceGroupMapService( _rockContext ).Queryable()
                                .Where( m => m.EventItemOccurrenceId == eventItemOccurrenceId )
                                .Select( m => m.Group )
                                .FirstOrDefault();

            var registrationLinkages = eventGroup.Linkages.ToList();

            if ( registrationLinkages.Count() == 0 )
            {
                lErrors.Text = "<div class='alert alert-warning'>No registration instances exists for this event.</div>";
                return;
            }

            EventItemOccurrenceGroupMap registrationLinkage = registrationLinkages.First();

            // create new registration
            var registrationService = new RegistrationService( rockContext );

            Registration registration = new Registration();
            registrationService.Add( registration );

            registration.RegistrationInstanceId = registrationLinkage.RegistrationInstanceId.Value;
            registration.ConfirmationEmail = ebEmailReminder.Text;
            registration.PersonAliasId = person.PrimaryAliasId;
            registration.FirstName = person.NickName;
            registration.LastName = person.LastName;
            registration.IsTemporary = true;

            // add registrants
            foreach ( int registrantId in cblRegistrants.SelectedValuesAsInt )
            {
                RegistrationRegistrant registrant = new RegistrationRegistrant();
                registrant.PersonAliasId = registrantId;
                registration.Registrants.Add( registrant );
            }

            rockContext.SaveChanges();

            // redirect to registration page
            var queryParams = new Dictionary<string, string>();
            queryParams.Add( "RegistrationInstanceId", registrationLinkage.RegistrationInstanceId.ToString());
            queryParams.Add( "RegistrationId", registration.Id.ToString() );
            queryParams.Add( "StartAtBeginning", GetAttributeValue( "StartRegistrationAtBeginning" ) );

            if ( !string.IsNullOrWhiteSpace( registrationLinkage.UrlSlug ) )
            {
                queryParams.Add( "Slug", registrationLinkage.UrlSlug );
            }

            if (registrationLinkage.Group != null)
            {
                queryParams.Add( "GroupId", registrationLinkage.GroupId.ToString() );
            }

            NavigateToLinkedPage( "RegistrationPage", queryParams );
        }
        /// <summary>
        /// Sets the registration state
        /// </summary>
        private bool SetRegistrationState()
        {
            string registrationSlug = PageParameter( SLUG_PARAM_NAME );
            int? registrationInstanceId = PageParameter( REGISTRATION_INSTANCE_ID_PARAM_NAME ).AsIntegerOrNull();
            int? registrationId = PageParameter( REGISTRATION_ID_PARAM_NAME ).AsIntegerOrNull();
            int? groupId = PageParameter( GROUP_ID_PARAM_NAME ).AsIntegerOrNull();
            int? campusId = PageParameter( CAMPUS_ID_PARAM_NAME ).AsIntegerOrNull();
            int? eventOccurrenceId = PageParameter( EVENT_OCCURRENCE_ID_PARAM_NAME ).AsIntegerOrNull();

            // Not inside a "using" due to serialization needing context to still be active
            var rockContext = new RockContext();

            // An existing registration id was specified
            if ( registrationId.HasValue )
            {
                var registrationService = new RegistrationService( rockContext );
                var registration = registrationService
                    .Queryable( "Registrants.PersonAlias.Person,Registrants.GroupMember,RegistrationInstance.Account,RegistrationInstance.RegistrationTemplate.Fees,RegistrationInstance.RegistrationTemplate.Discounts,RegistrationInstance.RegistrationTemplate.Forms.Fields.Attribute,RegistrationInstance.RegistrationTemplate.FinancialGateway" )
                    .Where( r => r.Id == registrationId.Value )
                    .FirstOrDefault();

                if ( registration == null )
                {
                    ShowError( "Error", "Registration not found" );
                    return false;
                }

                if ( CurrentPersonId == null )
                {
                    ShowWarning( "Please log in", "You must be logged in to access this registration." );
                    return false;
                }

                // Only allow the person that was logged in when this registration was created.
                // If the logged in person, registered on someone elses behalf (for example, husband logged in, but entered wife's name as the Registrar),
                // also allow that person to access the regisratiuon
                if ( ( registration.PersonAlias != null && registration.PersonAlias.PersonId == CurrentPersonId.Value ) ||
                    ( registration.CreatedByPersonAlias != null && registration.CreatedByPersonAlias.PersonId == CurrentPersonId.Value ) )
                {
                    RegistrationInstanceState = registration.RegistrationInstance;
                    RegistrationState = new RegistrationInfo( registration, rockContext );
                    RegistrationState.PreviousPaymentTotal = registrationService.GetTotalPayments( registration.Id );
                }
                else
                {
                    ShowWarning( "Sorry", "You are not allowed to view or edit the selected registration since you are not the one who created the registration." );
                    return false;
                }

                // set the max number of steps in the progress bar
                numHowMany.Value = registration.Registrants.Count();
                this.ProgressBarSteps = numHowMany.Value * FormCount + 2;

                // set group id
                if ( groupId.HasValue )
                {
                    GroupId = groupId;
                }
                else if ( !string.IsNullOrWhiteSpace( registrationSlug ) )
                {
                    var dateTime = RockDateTime.Now;
                    var linkage = new EventItemOccurrenceGroupMapService( rockContext )
                        .Queryable().AsNoTracking()
                        .Where( l =>
                            l.UrlSlug == registrationSlug &&
                            l.RegistrationInstance != null &&
                            l.RegistrationInstance.IsActive &&
                            l.RegistrationInstance.RegistrationTemplate != null &&
                            l.RegistrationInstance.RegistrationTemplate.IsActive &&
                            ( !l.RegistrationInstance.StartDateTime.HasValue || l.RegistrationInstance.StartDateTime <= dateTime ) &&
                            ( !l.RegistrationInstance.EndDateTime.HasValue || l.RegistrationInstance.EndDateTime > dateTime ) )
                        .FirstOrDefault();
                    if ( linkage != null )
                    {
                        GroupId = linkage.GroupId;
                    }
                }
            }

            // A registration slug was specified
            if ( RegistrationState == null && !string.IsNullOrWhiteSpace( registrationSlug ) )
            {
                var dateTime = RockDateTime.Now;
                var linkage = new EventItemOccurrenceGroupMapService( rockContext )
                    .Queryable( "RegistrationInstance.Account,RegistrationInstance.RegistrationTemplate.Fees,RegistrationInstance.RegistrationTemplate.Discounts,RegistrationInstance.RegistrationTemplate.Forms.Fields.Attribute,RegistrationInstance.RegistrationTemplate.FinancialGateway" )
                    .Where( l =>
                        l.UrlSlug == registrationSlug &&
                        l.RegistrationInstance != null &&
                        l.RegistrationInstance.IsActive &&
                        l.RegistrationInstance.RegistrationTemplate != null &&
                        l.RegistrationInstance.RegistrationTemplate.IsActive &&
                        ( !l.RegistrationInstance.StartDateTime.HasValue || l.RegistrationInstance.StartDateTime <= dateTime ) &&
                        ( !l.RegistrationInstance.EndDateTime.HasValue || l.RegistrationInstance.EndDateTime > dateTime ) )
                    .FirstOrDefault();

                if ( linkage != null )
                {
                    RegistrationInstanceState = linkage.RegistrationInstance;
                    GroupId = linkage.GroupId;
                    RegistrationState = new RegistrationInfo( CurrentPerson );
                }
            }

            // A group id and campus id were specified
            if ( RegistrationState == null && groupId.HasValue && campusId.HasValue )
            {
                var dateTime = RockDateTime.Now;
                var linkage = new EventItemOccurrenceGroupMapService( rockContext )
                    .Queryable( "RegistrationInstance.Account,RegistrationInstance.RegistrationTemplate.Fees,RegistrationInstance.RegistrationTemplate.Discounts,RegistrationInstance.RegistrationTemplate.Forms.Fields.Attribute,RegistrationInstance.RegistrationTemplate.FinancialGateway" )
                    .Where( l =>
                        l.GroupId == groupId &&
                        l.EventItemOccurrence != null &&
                        l.EventItemOccurrence.CampusId == campusId &&
                        l.RegistrationInstance != null &&
                        l.RegistrationInstance.IsActive &&
                        l.RegistrationInstance.RegistrationTemplate != null &&
                        l.RegistrationInstance.RegistrationTemplate.IsActive &&
                        ( !l.RegistrationInstance.StartDateTime.HasValue || l.RegistrationInstance.StartDateTime <= dateTime ) &&
                        ( !l.RegistrationInstance.EndDateTime.HasValue || l.RegistrationInstance.EndDateTime > dateTime ) )
                    .FirstOrDefault();

                CampusId = campusId;
                if ( linkage != null )
                {
                    RegistrationInstanceState = linkage.RegistrationInstance;
                    GroupId = linkage.GroupId;
                    RegistrationState = new RegistrationInfo( CurrentPerson );
                }
            }

            // A registration instance id was specified
            if ( RegistrationState == null && registrationInstanceId.HasValue )
            {
                var dateTime = RockDateTime.Now;
                RegistrationInstanceState = new RegistrationInstanceService( rockContext )
                    .Queryable( "Account,RegistrationTemplate.Fees,RegistrationTemplate.Discounts,RegistrationTemplate.Forms.Fields.Attribute,RegistrationTemplate.FinancialGateway" )
                    .Where( r =>
                        r.Id == registrationInstanceId.Value &&
                        r.IsActive &&
                        r.RegistrationTemplate != null &&
                        r.RegistrationTemplate.IsActive &&
                        ( !r.StartDateTime.HasValue || r.StartDateTime <= dateTime ) &&
                        ( !r.EndDateTime.HasValue || r.EndDateTime > dateTime ) )
                    .FirstOrDefault();

                if ( RegistrationInstanceState != null )
                {
                    RegistrationState = new RegistrationInfo( CurrentPerson );
                }
            }

            // If registration instance id and event occurrence were specified, but a group (linkage) hasn't been loaded, find the first group for the event occurrence
            if ( RegistrationInstanceState != null && eventOccurrenceId.HasValue && !groupId.HasValue )
            {
                var eventItemOccurrence = new EventItemOccurrenceService( rockContext )
                    .Queryable()
                    .Where( o => o.Id == eventOccurrenceId.Value )
                    .FirstOrDefault();
                if ( eventItemOccurrence != null )
                {
                    CampusId = eventItemOccurrence.CampusId;

                    var linkage = eventItemOccurrence.Linkages
                        .Where( l => l.RegistrationInstanceId == RegistrationInstanceState.Id )
                        .FirstOrDefault();

                    if ( linkage != null )
                    {
                        GroupId = linkage.GroupId;
                    }
                }
            }

            if ( RegistrationState != null &&
                RegistrationState.FamilyGuid == Guid.Empty &&
                RegistrationTemplate != null &&
                RegistrationTemplate.RegistrantsSameFamily != RegistrantsSameFamily.Ask )
            {
                RegistrationState.FamilyGuid = Guid.NewGuid();
            }

            if ( RegistrationState != null && !RegistrationState.Registrants.Any() )
            {
                SetRegistrantState( 1 );
            }

            if ( RegistrationTemplate != null &&
                RegistrationTemplate.FinancialGateway != null )
            {
                var threeStepGateway = RegistrationTemplate.FinancialGateway.GetGatewayComponent() as ThreeStepGatewayComponent;
                Using3StepGateway = threeStepGateway != null;
                if ( Using3StepGateway )
                {
                    Step2IFrameUrl = ResolveRockUrl( threeStepGateway.Step2FormUrl );
                }
            }

            return true;
        }
Beispiel #15
0
        protected void lbRegister_Click( object sender, EventArgs e )
        {
            // get registered group
            int eventItemOccurrenceId = hfSelectedEventId.Value.AsInteger();

            // look for the group for this event item
            var eventGroup = new EventItemOccurrenceGroupMapService( _rockContext ).Queryable()
                                .Where( m => m.EventItemOccurrenceId == eventItemOccurrenceId )
                                .Select(m => m.Group)
                                .FirstOrDefault();

            if ( eventGroup != null )
            {
                var groupMemberStats = this.GetAttributeValue( "GroupMemberStatus" ).ConvertToEnum<GroupMemberStatus>( GroupMemberStatus.Pending );

                Guid groupRoleGuid = GetAttributeValue( "GroupMemberRole" ).AsGuid();

                // check that the role is in the group
                var groupRoleId = new GroupTypeRoleService( _rockContext ).Queryable()
                                    .Where( r => r.Guid == groupRoleGuid && r.GroupType.Id == eventGroup.GroupTypeId )
                                    .Select( r => r.Id )
                                    .FirstOrDefault();

                if ( groupRoleId != 0 )
                {
                    List<string> registrantsAdded = new List<string>();
                    List<string> registransNotAdded = new List<string>();

                    foreach ( int registrantId in cblRegistrants.SelectedValuesAsInt )
                    {
                        var registrant = new PersonService( _rockContext ).Get( registrantId );

                        // check that the person is not already in the group with the current role
                        var inGroup = new GroupMemberService( _rockContext ).Queryable()
                                        .Where( m => m.PersonId == registrantId
                                                    && m.GroupRoleId == groupRoleId
                                                    && m.GroupId == eventGroup.Id )
                                        .Any();

                        if ( !inGroup )
                        {
                            GroupMember registrantGroupMember = new GroupMember();
                            registrantGroupMember.PersonId = registrantId;
                            registrantGroupMember.GroupId = eventGroup.Id;
                            registrantGroupMember.GroupRoleId = groupRoleId;
                            registrantGroupMember.GroupMemberStatus = groupMemberStats;
                            eventGroup.Members.Add( registrantGroupMember );

                            registrantsAdded.Add( registrant.NickName );
                        } else
                        {
                            registransNotAdded.Add( registrant.NickName );
                        }
                    }

                    _rockContext.SaveChanges();

                    string registeredMessage = string.Empty;
                    string notRegisteredMessage = string.Empty;

                    if ( registrantsAdded.Count > 0 )
                    {
                        string registerAction = "has";
                        if ( registrantsAdded.Count > 1 )
                        {
                            registerAction = "have";
                        }
                        registeredMessage = string.Format( "{0} {1} been registered.", registrantsAdded.Humanize(), registerAction );
                    }

                    if (registransNotAdded.Count > 0) {
                        string registerAction = "was";

                        if ( registransNotAdded.Count > 1 )
                        {
                            registerAction = "were";
                        }
                        notRegisteredMessage = string.Format( "{0} {1} already registered.", registransNotAdded.Humanize(), registerAction );
                    }

                    lCompleteMessage.Text = string.Format("<div class='alert alert-success'>{0} {1}</div>",
                                                    registeredMessage,
                                                    notRegisteredMessage );
                }
                else
                {
                    lCompleteMessage.Text = "<div class='alert alert-warning'>The role configured to use for adding the group member is not a part of this group.</div>";
                }
            }
            else
            {
                lCompleteMessage.Text = "<div class='alert alert-warning'>There is no group configured for this event.</div>";
            }
        }
        protected void lbRegister_Click(object sender, EventArgs e)
        {
            // get registered group
            int eventItemOccurrenceId = hfSelectedEventId.Value.AsInteger();

            // look for the group for this event item
            var eventGroup = new EventItemOccurrenceGroupMapService(_rockContext).Queryable()
                             .Where(m => m.EventItemOccurrenceId == eventItemOccurrenceId)
                             .Select(m => m.Group)
                             .FirstOrDefault();

            if (eventGroup != null)
            {
                var groupMemberStats = this.GetAttributeValue("GroupMemberStatus").ConvertToEnum <GroupMemberStatus>(GroupMemberStatus.Pending);

                Guid groupRoleGuid = GetAttributeValue("GroupMemberRole").AsGuid();

                // check that the role is in the group
                var groupRoleId = new GroupTypeRoleService(_rockContext).Queryable()
                                  .Where(r => r.Guid == groupRoleGuid && r.GroupType.Id == eventGroup.GroupTypeId)
                                  .Select(r => r.Id)
                                  .FirstOrDefault();

                if (groupRoleId != 0)
                {
                    List <string> registrantsAdded   = new List <string>();
                    List <string> registransNotAdded = new List <string>();

                    foreach (int registrantId in cblRegistrants.SelectedValuesAsInt)
                    {
                        var registrant = new PersonService(_rockContext).Get(registrantId);

                        // check that the person is not already in the group with the current role
                        var inGroup = new GroupMemberService(_rockContext).Queryable()
                                      .Where(m => m.PersonId == registrantId &&
                                             m.GroupRoleId == groupRoleId &&
                                             m.GroupId == eventGroup.Id)
                                      .Any();

                        if (!inGroup)
                        {
                            GroupMember registrantGroupMember = new GroupMember();
                            registrantGroupMember.PersonId          = registrantId;
                            registrantGroupMember.GroupId           = eventGroup.Id;
                            registrantGroupMember.GroupRoleId       = groupRoleId;
                            registrantGroupMember.GroupMemberStatus = groupMemberStats;
                            eventGroup.Members.Add(registrantGroupMember);

                            registrantsAdded.Add(registrant.NickName);
                        }
                        else
                        {
                            registransNotAdded.Add(registrant.NickName);
                        }
                    }

                    _rockContext.SaveChanges();

                    string registeredMessage    = string.Empty;
                    string notRegisteredMessage = string.Empty;

                    if (registrantsAdded.Count > 0)
                    {
                        string registerAction = "has";
                        if (registrantsAdded.Count > 1)
                        {
                            registerAction = "have";
                        }
                        registeredMessage = string.Format("{0} {1} been registered.", registrantsAdded.Humanize(), registerAction);
                    }

                    if (registransNotAdded.Count > 0)
                    {
                        string registerAction = "was";

                        if (registransNotAdded.Count > 1)
                        {
                            registerAction = "were";
                        }
                        notRegisteredMessage = string.Format("{0} {1} already registered.", registransNotAdded.Humanize(), registerAction);
                    }

                    lCompleteMessage.Text = string.Format("<div class='alert alert-success'>{0} {1}</div>",
                                                          registeredMessage,
                                                          notRegisteredMessage);
                }
                else
                {
                    lCompleteMessage.Text = "<div class='alert alert-warning'>The role configured to use for adding the group member is not a part of this group.</div>";
                }
            }
            else
            {
                lCompleteMessage.Text = "<div class='alert alert-warning'>There is no group configured for this event.</div>";
            }
        }
Beispiel #17
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)
        {
            EventItemOccurrence eventItemOccurrence = null;

            using (var rockContext = new RockContext())
            {
                bool newItem = false;
                var  eventItemOccurrenceService         = new EventItemOccurrenceService(rockContext);
                var  eventItemOccurrenceGroupMapService = new EventItemOccurrenceGroupMapService(rockContext);
                var  registrationInstanceService        = new RegistrationInstanceService(rockContext);
                var  scheduleService = new ScheduleService(rockContext);

                int eventItemOccurrenceId = hfEventItemOccurrenceId.ValueAsInt();
                if (eventItemOccurrenceId != 0)
                {
                    eventItemOccurrence = eventItemOccurrenceService
                                          .Queryable("Linkages")
                                          .Where(i => i.Id == eventItemOccurrenceId)
                                          .FirstOrDefault();
                }

                if (eventItemOccurrence == null)
                {
                    newItem             = true;
                    eventItemOccurrence = new EventItemOccurrence {
                        EventItemId = PageParameter("EventItemId").AsInteger()
                    };
                    eventItemOccurrenceService.Add(eventItemOccurrence);
                }

                int?newCampusId = ddlCampus.SelectedValueAsInt();
                if (eventItemOccurrence.CampusId != newCampusId)
                {
                    eventItemOccurrence.CampusId = newCampusId;
                    if (newCampusId.HasValue)
                    {
                        var campus = new CampusService(rockContext).Get(newCampusId.Value);
                        eventItemOccurrence.Campus = campus;
                    }
                    else
                    {
                        eventItemOccurrence.Campus = null;
                    }
                }

                eventItemOccurrence.Location = tbLocation.Text;

                string iCalendarContent = sbSchedule.iCalendarContent;
                var    calEvent         = ScheduleICalHelper.GetCalenderEvent(iCalendarContent);
                if (calEvent != null && calEvent.DTStart != null)
                {
                    if (eventItemOccurrence.Schedule == null)
                    {
                        eventItemOccurrence.Schedule = new Schedule();
                    }
                    eventItemOccurrence.Schedule.iCalendarContent = iCalendarContent;
                }
                else
                {
                    if (eventItemOccurrence.ScheduleId.HasValue)
                    {
                        var oldSchedule = scheduleService.Get(eventItemOccurrence.ScheduleId.Value);
                        if (oldSchedule != null)
                        {
                            scheduleService.Delete(oldSchedule);
                        }
                    }
                }

                if (!eventItemOccurrence.ContactPersonAliasId.Equals(ppContact.PersonAliasId))
                {
                    PersonAlias personAlias = null;
                    eventItemOccurrence.ContactPersonAliasId = ppContact.PersonAliasId;
                    if (eventItemOccurrence.ContactPersonAliasId.HasValue)
                    {
                        personAlias = new PersonAliasService(rockContext).Get(eventItemOccurrence.ContactPersonAliasId.Value);
                    }

                    if (personAlias != null)
                    {
                        eventItemOccurrence.ContactPersonAlias = personAlias;
                    }
                }

                eventItemOccurrence.ContactPhone = PhoneNumber.FormattedNumber(PhoneNumber.DefaultCountryCode(), pnPhone.Number);
                eventItemOccurrence.ContactEmail = tbEmail.Text;
                eventItemOccurrence.Note         = htmlOccurrenceNote.Text;

                // Remove any linkage no longer in UI
                Guid uiLinkageGuid = LinkageState != null ? LinkageState.Guid : Guid.Empty;
                foreach (var linkage in eventItemOccurrence.Linkages.Where(l => !l.Guid.Equals(uiLinkageGuid)).ToList())
                {
                    eventItemOccurrence.Linkages.Remove(linkage);
                    eventItemOccurrenceGroupMapService.Delete(linkage);
                }

                // Add/Update linkage in UI
                if (!uiLinkageGuid.Equals(Guid.Empty))
                {
                    var linkage = eventItemOccurrence.Linkages.Where(l => l.Guid.Equals(uiLinkageGuid)).FirstOrDefault();
                    if (linkage == null)
                    {
                        linkage = new EventItemOccurrenceGroupMap();
                        eventItemOccurrence.Linkages.Add(linkage);
                    }
                    linkage.CopyPropertiesFrom(LinkageState);

                    // update registration instance
                    if (LinkageState.RegistrationInstance != null)
                    {
                        if (LinkageState.RegistrationInstance.Id != 0)
                        {
                            linkage.RegistrationInstance = registrationInstanceService.Get(LinkageState.RegistrationInstance.Id);
                        }

                        if (linkage.RegistrationInstance == null)
                        {
                            var registrationInstance = new RegistrationInstance();
                            registrationInstanceService.Add(registrationInstance);
                            linkage.RegistrationInstance = registrationInstance;
                        }

                        linkage.RegistrationInstance.CopyPropertiesFrom(LinkageState.RegistrationInstance);
                    }
                }

                if (!Page.IsValid)
                {
                    return;
                }

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

                rockContext.SaveChanges();

                var qryParams = new Dictionary <string, string>();
                qryParams.Add("EventCalendarId", PageParameter("EventCalendarId"));
                qryParams.Add("EventItemId", PageParameter("EventItemId"));

                if (newItem)
                {
                    NavigateToParentPage(qryParams);
                }
                else
                {
                    qryParams.Add("EventItemOccurrenceId", eventItemOccurrence.Id.ToString());
                    NavigateToPage(RockPage.Guid, qryParams);
                }
            }
        }
        private void ShowNewLinkageDialog()
        {
            rieNewLinkage.ShowActive = false;
            rieNewLinkage.ShowUrlSlug = true;

            ddlNewLinkageTemplate.Items.Clear();

            using ( var rockContext = new RockContext() )
            {
                // Find most recent mapping with same event, campus and copy some of it's registration instance values
                int EventItemId = PageParameter( "EventItemId" ).AsInteger();
                int? campusId = ddlCampus.SelectedValueAsInt();
                var registrationInstance = new EventItemOccurrenceGroupMapService( rockContext )
                    .Queryable()
                    .Where( m =>
                        m.EventItemOccurrence != null &&
                        m.EventItemOccurrence.EventItemId == EventItemId &&
                        m.RegistrationInstance != null &&
                        (
                            ( campusId.HasValue && ( !m.EventItemOccurrence.CampusId.HasValue || m.EventItemOccurrence.CampusId.Value == campusId.Value ) ) ||
                            ( !campusId.HasValue && !m.EventItemOccurrence.CampusId.HasValue )
                        )
                    )
                    .ToList()
                    .OrderByDescending( m => m.EventItemOccurrence.NextStartDateTime )
                    .Select( m => m.RegistrationInstance )
                    .FirstOrDefault();

                if ( registrationInstance != null )
                {
                    LinkageState.RegistrationInstance = new RegistrationInstance();
                    LinkageState.RegistrationInstance.AccountId = registrationInstance.AccountId;
                    LinkageState.RegistrationInstance.RegistrationTemplateId = registrationInstance.RegistrationTemplateId;
                    LinkageState.RegistrationInstance.RegistrationTemplate = new RegistrationTemplate();
                    LinkageState.RegistrationInstance.ContactPersonAliasId = registrationInstance.ContactPersonAliasId;
                    LinkageState.RegistrationInstance.ContactPhone = registrationInstance.ContactPhone;
                    LinkageState.RegistrationInstance.ContactEmail = registrationInstance.ContactEmail;
                    LinkageState.RegistrationInstance.AdditionalReminderDetails = registrationInstance.AdditionalReminderDetails;
                    LinkageState.RegistrationInstance.AdditionalConfirmationDetails = registrationInstance.AdditionalConfirmationDetails;
                    var registrationTemplate = new RegistrationTemplateService( rockContext ).Get( registrationInstance.RegistrationTemplateId );
                    if ( registrationTemplate != null )
                    {
                        LinkageState.RegistrationInstance.RegistrationTemplate.CopyPropertiesFrom( registrationTemplate );
                    }
                }

                foreach ( var template in new RegistrationTemplateService( rockContext )
                    .Queryable().AsNoTracking().OrderBy(t => t.Name ))
                {
                    if ( template.IsAuthorized( Authorization.VIEW, CurrentPerson ) )
                    {
                        ListItem li = new ListItem( template.Name, template.Id.ToString() );
                        ddlNewLinkageTemplate.Items.Add( li );
                        li.Selected = LinkageState.RegistrationInstance != null &&
                            LinkageState.RegistrationInstance.RegistrationTemplateId == template.Id;
                    }
                }

                gpNewLinkageGroup.SetValue( LinkageState.Group );

                rieNewLinkage.SetValue( LinkageState.RegistrationInstance );
                rieNewLinkage.UrlSlug = LinkageState.UrlSlug;

                if ( LinkageState.RegistrationInstance == null )
                {
                    var contactPersonAliasId = ppContact.PersonAliasId;
                    if ( contactPersonAliasId.HasValue )
                    {
                        var personAlias = new PersonAliasService( rockContext ).Get( contactPersonAliasId.Value );
                        if ( personAlias != null )
                        {
                            rieNewLinkage.ContactPersonAlias = personAlias;
                        }
                    }

                    if ( !string.IsNullOrWhiteSpace( pnPhone.Text))
                    {
                        rieNewLinkage.ContactPhone = pnPhone.Text;
                    }

                    if ( !string.IsNullOrWhiteSpace( tbEmail.Text ) )
                    {
                        rieNewLinkage.ContactEmail = tbEmail.Text;
                    }

                    Guid? accountGuid = GetAttributeValue( "DefaultAccount" ).AsGuidOrNull();
                    if ( accountGuid.HasValue )
                    {
                        var account = new FinancialAccountService( rockContext ).Get( accountGuid.Value );
                        rieNewLinkage.AccountId = account != null ? account.Id : 0;
                    }

                }
            }

            ShowDialog( "EventItemNewLinkage", true );
        }
Beispiel #19
0
        /// <summary>
        /// Sets the registration state
        /// </summary>
        private void SetRegistrationState()
        {
            string registrationSlug = PageParameter( REGISTRATION_SLUG_PARAM_NAME );
            int? registrationInstanceId = PageParameter( REGISTRATION_INSTANCE_ID_PARAM_NAME ).AsIntegerOrNull();
            int? registrationId = PageParameter( REGISTRATION_ID_PARAM_NAME ).AsIntegerOrNull();
            int? groupId = PageParameter( REGISTRATION_GROUP_ID_PARAM_NAME ).AsIntegerOrNull();
            int? campusId = PageParameter( REGISTRATION_CAMPUS_ID_PARAM_NAME ).AsIntegerOrNull();

            // Not inside a "using" due to serialization needing context to still be active
            var rockContext = new RockContext();

            // An existing registration id was specified
            if ( registrationId.HasValue )
            {
                var registrationService = new RegistrationService( rockContext );
                var registration = registrationService
                    .Queryable( "Registrants.PersonAlias.Person,Registrants.GroupMember,RegistrationInstance.Account,RegistrationInstance.RegistrationTemplate.Fees,RegistrationInstance.RegistrationTemplate.Discounts,RegistrationInstance.RegistrationTemplate.Forms.Fields.Attribute,RegistrationInstance.RegistrationTemplate.FinancialGateway" )
                    .Where( r => r.Id == registrationId.Value )
                    .FirstOrDefault();
                if ( registration != null )
                {
                    RegistrationInstanceState = registration.RegistrationInstance;
                    RegistrationState = new RegistrationInfo( registration, rockContext );
                    RegistrationState.PreviousPaymentTotal = registrationService.GetTotalPayments( registration.Id );
                }
            }

            // A registration slug was specified
            if ( RegistrationState == null && !string.IsNullOrWhiteSpace( registrationSlug ) )
            {
                var dateTime = RockDateTime.Now;
                var linkage = new EventItemOccurrenceGroupMapService( rockContext )
                    .Queryable( "RegistrationInstance.Account,RegistrationInstance.RegistrationTemplate.Fees,RegistrationInstance.RegistrationTemplate.Discounts,RegistrationInstance.RegistrationTemplate.Forms.Fields.Attribute,RegistrationInstance.RegistrationTemplate.FinancialGateway" )
                    .Where( l =>
                        l.UrlSlug == registrationSlug &&
                        l.RegistrationInstance != null &&
                        l.RegistrationInstance.IsActive &&
                        l.RegistrationInstance.RegistrationTemplate != null &&
                        l.RegistrationInstance.RegistrationTemplate.IsActive &&
                        (!l.RegistrationInstance.StartDateTime.HasValue || l.RegistrationInstance.StartDateTime <= dateTime ) &&
                        (!l.RegistrationInstance.EndDateTime.HasValue || l.RegistrationInstance.EndDateTime > dateTime )  )
                    .FirstOrDefault();

                if ( linkage != null )
                {
                    RegistrationInstanceState = linkage.RegistrationInstance;
                    GroupId = linkage.GroupId;
                    RegistrationState = new RegistrationInfo( CurrentPerson );
                }
            }

            // A group id and campus id were specified
            if ( RegistrationState == null && groupId.HasValue && campusId.HasValue )
            {
                var dateTime = RockDateTime.Now;
                var linkage = new EventItemOccurrenceGroupMapService( rockContext )
                    .Queryable( "RegistrationInstance.Account,RegistrationInstance.RegistrationTemplate.Fees,RegistrationInstance.RegistrationTemplate.Discounts,RegistrationInstance.RegistrationTemplate.Forms.Fields.Attribute,RegistrationInstance.RegistrationTemplate.FinancialGateway" )
                    .Where( l =>
                        l.GroupId == groupId &&
                        l.EventItemOccurrence != null &&
                        l.EventItemOccurrence.CampusId == campusId &&
                        l.RegistrationInstance != null &&
                        l.RegistrationInstance.IsActive &&
                        l.RegistrationInstance.RegistrationTemplate != null &&
                        l.RegistrationInstance.RegistrationTemplate.IsActive &&
                        ( !l.RegistrationInstance.StartDateTime.HasValue || l.RegistrationInstance.StartDateTime <= dateTime ) &&
                        ( !l.RegistrationInstance.EndDateTime.HasValue || l.RegistrationInstance.EndDateTime > dateTime ) )
                    .FirstOrDefault();

                if ( linkage != null )
                {
                    RegistrationInstanceState = linkage.RegistrationInstance;
                    GroupId = linkage.GroupId;
                    RegistrationState = new RegistrationInfo( CurrentPerson );
                }
            }

            // A registratio instance id was specified
            if ( RegistrationState == null && registrationInstanceId.HasValue )
            {
                var dateTime = RockDateTime.Now;
                RegistrationInstanceState = new RegistrationInstanceService( rockContext )
                    .Queryable( "Account,RegistrationTemplate.Fees,RegistrationTemplate.Discounts,RegistrationTemplate.Forms.Fields.Attribute,RegistrationTemplate.FinancialGateway" )
                    .Where( r =>
                        r.Id == registrationInstanceId.Value &&
                        r.IsActive &&
                        r.RegistrationTemplate != null &&
                        r.RegistrationTemplate.IsActive &&
                        ( !r.StartDateTime.HasValue || r.StartDateTime <= dateTime ) &&
                        ( !r.EndDateTime.HasValue || r.EndDateTime > dateTime ) )
                    .FirstOrDefault();

                if ( RegistrationInstanceState != null )
                {
                    RegistrationState = new RegistrationInfo( CurrentPerson );
                }
            }

            if ( RegistrationState != null && !RegistrationState.Registrants.Any() )
            {
                SetRegistrantState( 1 );
            }
        }
        /// <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 )
        {
            EventItemOccurrence eventItemOccurrence = null;

            using ( var rockContext = new RockContext() )
            {
                bool newItem = false;
                var eventItemOccurrenceService = new EventItemOccurrenceService( rockContext );
                var eventItemOccurrenceGroupMapService = new EventItemOccurrenceGroupMapService( rockContext );
                var registrationInstanceService = new RegistrationInstanceService( rockContext );
                var scheduleService = new ScheduleService( rockContext );

                int eventItemOccurrenceId = hfEventItemOccurrenceId.ValueAsInt();
                if ( eventItemOccurrenceId != 0 )
                {
                    eventItemOccurrence = eventItemOccurrenceService
                        .Queryable( "Linkages" )
                        .Where( i => i.Id == eventItemOccurrenceId )
                        .FirstOrDefault();
                }

                if ( eventItemOccurrence == null )
                {
                    newItem = true;
                    eventItemOccurrence = new EventItemOccurrence{ EventItemId = PageParameter("EventItemId").AsInteger() };
                    eventItemOccurrenceService.Add( eventItemOccurrence );
                }

                int? newCampusId = ddlCampus.SelectedValueAsInt();
                if ( eventItemOccurrence.CampusId != newCampusId )
                {
                    eventItemOccurrence.CampusId = newCampusId;
                    if ( newCampusId.HasValue )
                    {
                        var campus = new CampusService( rockContext ).Get( newCampusId.Value );
                        eventItemOccurrence.Campus = campus;
                    }
                    else
                    {
                        eventItemOccurrence.Campus = null;
                    }
                }

                eventItemOccurrence.Location = tbLocation.Text;

                string iCalendarContent = sbSchedule.iCalendarContent;
                var calEvent = ScheduleICalHelper.GetCalenderEvent( iCalendarContent );
                if ( calEvent != null && calEvent.DTStart != null )
                {
                    if ( eventItemOccurrence.Schedule == null )
                    {
                        eventItemOccurrence.Schedule = new Schedule();
                    }
                    eventItemOccurrence.Schedule.iCalendarContent = iCalendarContent;
                }
                else
                {
                    if ( eventItemOccurrence.ScheduleId.HasValue )
                    {
                        var oldSchedule = scheduleService.Get( eventItemOccurrence.ScheduleId.Value );
                        if ( oldSchedule != null )
                        {
                            scheduleService.Delete( oldSchedule );
                        }
                    }
                }

                if ( !eventItemOccurrence.ContactPersonAliasId.Equals( ppContact.PersonAliasId ))
                {
                    PersonAlias personAlias = null;
                    eventItemOccurrence.ContactPersonAliasId = ppContact.PersonAliasId;
                    if ( eventItemOccurrence.ContactPersonAliasId.HasValue )
                    {
                        personAlias = new PersonAliasService( rockContext ).Get( eventItemOccurrence.ContactPersonAliasId.Value );
                    }

                    if ( personAlias != null )
                    {
                        eventItemOccurrence.ContactPersonAlias = personAlias;
                    }
                }

                eventItemOccurrence.ContactPhone = PhoneNumber.FormattedNumber( PhoneNumber.DefaultCountryCode(), pnPhone.Number );
                eventItemOccurrence.ContactEmail = tbEmail.Text;
                eventItemOccurrence.Note = htmlOccurrenceNote.Text;

                // Remove any linkage no longer in UI
                Guid uiLinkageGuid = LinkageState != null ? LinkageState.Guid : Guid.Empty;
                foreach( var linkage in eventItemOccurrence.Linkages.Where( l => !l.Guid.Equals(uiLinkageGuid)).ToList())
                {
                    eventItemOccurrence.Linkages.Remove( linkage );
                    eventItemOccurrenceGroupMapService.Delete( linkage );
                }

                // Add/Update linkage in UI
                if ( !uiLinkageGuid.Equals( Guid.Empty ))
                {
                    var linkage = eventItemOccurrence.Linkages.Where( l => l.Guid.Equals( uiLinkageGuid)).FirstOrDefault();
                    if ( linkage == null )
                    {
                        linkage = new EventItemOccurrenceGroupMap();
                        eventItemOccurrence.Linkages.Add( linkage );
                    }
                    linkage.CopyPropertiesFrom( LinkageState );

                    // update registration instance
                    if ( LinkageState.RegistrationInstance != null )
                    {
                        if ( LinkageState.RegistrationInstance.Id != 0 )
                        {
                            linkage.RegistrationInstance = registrationInstanceService.Get( LinkageState.RegistrationInstance.Id );
                        }

                        if ( linkage.RegistrationInstance == null )
                        {
                            var registrationInstance = new RegistrationInstance();
                            registrationInstanceService.Add( registrationInstance );
                            linkage.RegistrationInstance = registrationInstance;
                        }

                        linkage.RegistrationInstance.CopyPropertiesFrom( LinkageState.RegistrationInstance );
                    }

                }

                if ( !Page.IsValid )
                {
                    return;
                }

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

                rockContext.SaveChanges();

                var qryParams = new Dictionary<string, string>();
                qryParams.Add( "EventCalendarId", PageParameter( "EventCalendarId" ) );
                qryParams.Add( "EventItemId", PageParameter( "EventItemId" ) );

                if ( newItem )
                {
                    NavigateToParentPage( qryParams );
                }
                else
                {
                    qryParams.Add( "EventItemOccurrenceId", eventItemOccurrence.Id.ToString() );
                    NavigateToPage( RockPage.Guid, qryParams );
                }
            }
        }