예제 #1
0
        protected void btnNext_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (CurrentPageIndex == 0)
                {
                    string locationKey = GetLocationKey();
                    if (!string.IsNullOrEmpty(locationKey) && !_verifiedLocations.ContainsKey(locationKey))
                    {
                        using (var rockContext = new RockContext())
                        {
                            var location = new LocationService(rockContext).Get(acAddress.Street1, acAddress.Street2, acAddress.City, acAddress.State, acAddress.PostalCode, acAddress.Country);
                            _verifiedLocations.AddOrIgnore(locationKey, (location != null ? location.Id : (int?)null));
                        }
                    }
                }

                if (CurrentPageIndex < (attributeControls.Count + 1))
                {
                    CurrentPageIndex++;
                    CreateControls(true);
                }
                else
                {
                    if (FamilyMembers.Any())
                    {
                        if (CurrentPageIndex == (attributeControls.Count + 1) && FindDuplicates())
                        {
                            CurrentPageIndex++;
                            CreateControls(true);
                        }
                        else
                        {
                            var rockContext = new RockContext();
                            rockContext.WrapTransaction(() =>
                            {
                                var familyGroup = GroupService.SaveNewFamily(rockContext, FamilyMembers, cpCampus.SelectedValueAsInt(), true);
                                if (familyGroup != null)
                                {
                                    string locationKey = GetLocationKey();
                                    if (!string.IsNullOrEmpty(locationKey) && _verifiedLocations.ContainsKey(locationKey))
                                    {
                                        GroupService.AddNewFamilyAddress(rockContext, familyGroup, GetAttributeValue("LocationType"), _verifiedLocations[locationKey]);
                                    }
                                }
                            });

                            Response.Redirect(string.Format("~/Person/{0}", FamilyMembers[0].Person.Id), false);
                        }
                    }
                }
            }
        }
예제 #2
0
        void lbRemoveMember_Click(object sender, EventArgs e)
        {
            Guid personGuid   = ((LinkButton)sender).ID.Substring(15).Replace("_", "-").AsGuid();
            var  familyMember = FamilyMembers.Where(f => f.Person.Guid.Equals(personGuid)).FirstOrDefault();

            if (familyMember != null)
            {
                FamilyMembers.Remove(familyMember);
                Duplicates.Remove(personGuid);
                if (!FamilyMembers.Any())
                {
                    AddFamilyMember();
                    CurrentPageIndex = 0;
                }
                CreateControls(true);
            }
        }
예제 #3
0
        protected void btnNext_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (CurrentPageIndex < (attributeControls.Count + 1))
                {
                    CurrentPageIndex++;
                    CreateControls(true);
                }
                else
                {
                    if (FamilyMembers.Any())
                    {
                        if (CurrentPageIndex == (attributeControls.Count + 1) && FindDuplicates())
                        {
                            CurrentPageIndex++;
                            CreateControls(true);
                        }
                        else
                        {
                            var rockContext = new RockContext();
                            rockContext.WrapTransaction(() =>
                            {
                                var familyGroup = GroupService.SaveNewFamily(rockContext, FamilyMembers, cpCampus.SelectedValueAsInt(), true);
                                if (familyGroup != null)
                                {
                                    GroupService.AddNewFamilyAddress(rockContext, familyGroup, GetAttributeValue("LocationType"),
                                                                     acAddress.Street1, acAddress.Street2, acAddress.City, acAddress.State, acAddress.PostalCode, acAddress.Country);
                                }
                            });

                            Response.Redirect(string.Format("~/Person/{0}", FamilyMembers[0].Person.Id), false);
                        }
                    }
                }
            }
        }