Exemplo n.º 1
0
        private bool EmailRequiredForThisRegistration(string foundname)
        {
            var needemail = !person.EmailAddress.HasValue() &&
                            (ManageSubscriptions() ||
                             orgid == Util.CreateAccountCode ||
                             OnlineGiving() ||
                             ManageGiving() ||
                             OnlinePledge() ||
                             !EmailAddress.HasValue()     // register emai
                            );

            if (!needemail)
            {
                return(false);
            }
            modelState.AddModelError(foundname, "No Email Address on record");
            Log("NoEmailOnRecord");
            RegistrantProblem  = @"
** No Email Address on Record**
We have found your record but we have no email address for you.
This means that we cannot proceed until we have that to protect your data.
Please call the church to resolve this before we can complete your information.";
            IsValidForContinue = false;
            IsValidForExisting = false;
            return(true);
        }
Exemplo n.º 2
0
 private void ValidateEmail()
 {
     if (!IsFamily && (!EmailAddress.HasValue() || !Util.ValidEmail(EmailAddress)))
     {
         if (!Util.ValidEmail(person.EmailAddress))
         {
             modelState.AddModelError(Parent.GetNameFor(mm => mm.List[Index].EmailAddress),
                                      "Please specify a valid email address.");
             Log("InvalidEmail");
         }
     }
 }
Exemplo n.º 3
0
        private void ValidateEmailForNew()
        {
            if (EmailAddress.HasValue())
            {
                EmailAddress = EmailAddress.Trim();
            }

            if (EmailAddress.HasValue() && Util.ValidEmail(EmailAddress))
            {
                return;
            }

            modelState.AddModelError(Parent.GetNameFor(mm => mm.List[Index].person.EmailAddress),
                                     "Please specify a valid email address.");
            Log("NeedValidEmail");
        }
Exemplo n.º 4
0
 private void ValidateEmail()
 {
     if (!EmailAddress.HasValue() || !Util.ValidEmail(EmailAddress))
     {
         if (person == null)
         {
             modelState.AddModelError(Parent.GetNameFor(mm => mm.List[Index].EmailAddress),
                                      "Please specify a valid email address.");
             Log("InvalidEmail");
         }
         else if (!Util.ValidEmail(person.EmailAddress))
         {
             modelState.AddModelError(Parent.GetNameFor(mm => mm.List[Index].EmailAddress),
                                      "No valid email address needed for confirmation on record");
             Log("InvalidEmailOnRecord");
         }
     }
 }
Exemplo n.º 5
0
 private void ValidateEmail()
 {
     if (!EmailAddress.HasValue() || !Util.ValidEmail(EmailAddress.Trim()))
     {
         if (person == null)
         {
             modelState.AddModelError(Parent.GetNameFor(mm => mm.List[Index].EmailAddress),
                                      "Please specify a valid email address.");
             Log("InvalidEmail");
         }
         else if (!Util.ValidEmail(person.EmailAddress?.Trim()))
         {
             modelState.AddModelError(Parent.GetNameFor(mm => mm.List[Index].EmailAddress),
                                      "A valid email address is required");
             Log("InvalidEmailOnRecord");
         }
     }
 }
Exemplo n.º 6
0
        public void ValidateModelForFind(ModelStateDictionary ModelState, OnlineRegModel m, int i, bool selectfromfamily = false)
        {
            IsValidForContinue = true; // true till proven false
            if (UserSelectsOrganization())
            {
                if ((classid ?? 0) == 0)
                {
                    var          nameclassid             = Parent.GetNameFor(mm => mm.List[i].classid);
                    const string pleaseChooseAGroupEvent = "please choose a group/event";
                    if (IsFamily)
                    {
                        ModelState.AddModelError(nameclassid, pleaseChooseAGroupEvent);
                    }
                    else
                    {
                        ModelState.AddModelError(nameclassid, pleaseChooseAGroupEvent);
                    }
                    IsValidForExisting = ModelState.IsValid;
                    return;
                }
            }
            var dobname   = Parent.GetNameFor(mm => mm.List[i].DateOfBirth);
            var foundname = Parent.GetNameFor(mm => mm.List[i].Found);

            if (IsFamily)
            {
                foundname = "fammember-" + PeopleId;
            }
            if (!PeopleId.HasValue)
            {
                ValidBasic(ModelState, i);
            }
            if (ComputesOrganizationByAge() && !birthday.HasValue)
            {
                ModelState.AddModelError(dobname, "birthday required");
            }
            var minage = DbUtil.Db.Setting("MinimumUserAge", "16").ToInt();

            if (orgid == Util.CreateAccountCode && age < minage)
            {
                ModelState.AddModelError(dobname, "must be {0} to create account".Fmt(minage));
            }
            if (!IsFamily && (!EmailAddress.HasValue() || !Util.ValidEmail(EmailAddress)))
            {
                ModelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].EmailAddress), "Please specify a valid email address.");
            }
            if (ModelState.IsValid)
            {
                Found = person != null;
                if (count == 1)
                {
                    AddressLineOne = person.PrimaryAddress;
                    City           = person.PrimaryCity;
                    State          = person.PrimaryState;
                    ZipCode        = person.PrimaryZip;
                    gender         = person.GenderId;
                    married        = person.MaritalStatusId == 2 ? 2 : 1;

                    if (!person.EmailAddress.HasValue() &&
                        (ManageSubscriptions() ||
                         orgid == Util.CreateAccountCode ||
                         OnlineGiving() ||
                         ManageGiving() ||
                         OnlinePledge()
                        ))
                    {
                        ModelState.AddModelError(foundname, "No Email Address on record");
                        NotFoundText       = @"<strong>No Email Address on Record</strong><br/>
We have found your record but we have no email address for you.<br/>
This means that we cannot proceed until we have that to protect your data.<br/>
Please call the church to resolve this before we can complete your information.";
                        IsValidForContinue = false;
                    }
                    else if (ComputesOrganizationByAge() && org == null)
                    {
                        var msg = NoAppropriateOrgError ?? "Sorry, no approprate org";
                        if (selectfromfamily)
                        {
                            ModelState.AddModelError("age-" + person.PeopleId, msg);
                        }
                        else
                        {
                            ModelState.AddModelError(dobname, msg);
                        }
                        IsValidForContinue = false;
                    }
                    else if (MemberOnly() && person.MemberStatusId != MemberStatusCode.Member)
                    {
                        ModelState.AddModelError(foundname, "Sorry, must be a member of church");
                        if (setting.UseBootstrap)
                        {
                            NotFoundText = @"<strong>Sorry, must be a member of this church</strong>";
                        }
                        IsValidForContinue = false;
                    }
                    else if (org != null)
                    {
                        var om = org.OrganizationMembers.SingleOrDefault(mm => mm.PeopleId == PeopleId);
                        if (org.RegistrationTypeId == RegistrationTypeCode.CreateAccount)
                        {
#if DEBUG
#else
                            if (person.Users.Count() > 0)
                            {
                                ModelState.AddModelError(foundname, "You already have an account");
                                IsValidForContinue = false;
                            }
                            if (!Util.ValidEmail(person.EmailAddress))
                            {
                                ModelState.AddModelError(foundname, "You must have a valid email address on record");
                                NotFoundText       = @"We have found your record but we do not have a valid email for you.<br/>
For your protection, we cannot continue to create an account.<br />
We can't use the one you enter online here since we can't be sure this is you.<br />
Please call the church to resolve this before we can complete your account.<br />";
                                IsValidForContinue = false;
                            }
#endif
                        }
                        else if (om != null && org.IsMissionTrip == true &&
                                 !Parent.SupportMissionTrip &&
                                 om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == "Sender") &&
                                 !om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == "Goer"))
                        {
                            IsValidForContinue = true;
                        }
                        else if (om != null && setting.AllowReRegister == false &&
                                 om.Organization.RegistrationTypeId != RegistrationTypeCode.ChooseVolunteerTimes &&
                                 !Parent.SupportMissionTrip)
                        {
                            ModelState.AddModelError(foundname, "This person is already registered");
                            if (setting.UseBootstrap || Parent.UseBootstrap)
                            {
                                NotFoundText = @"<strong>This person is already registered</strong>";
                            }
                            CancelText         = "Regiser a different person";
                            IsValidForContinue = false;
                        }
                        else if (setting.ValidateOrgIds.Count > 0)
                        {
                            var reqmemberids = setting.ValidateOrgIds.Where(ii => ii > 0).ToList();
                            if (reqmemberids.Count > 0)
                            {
                                if (!person.OrganizationMembers.Any(mm => reqmemberids.Contains(mm.OrganizationId)))
                                {
                                    ModelState.AddModelError(foundname, "Must be member of specified organization");
                                    if (setting.UseBootstrap)
                                    {
                                        NotFoundText = @"<strong>Must be a member of specified organization to register</strong>";
                                    }
                                    IsValidForContinue = false;
                                }
                            }
                            var reqnomemberids = setting.ValidateOrgIds.Where(ii => ii < 0).ToList();
                            if (reqnomemberids.Count > 0)
                            {
                                if (person.OrganizationMembers.Any(mm => reqnomemberids.Contains(-mm.OrganizationId)))
                                {
                                    ModelState.AddModelError(foundname, "Must not be a member of specified organization");
                                    if (setting.UseBootstrap)
                                    {
                                        NotFoundText = @"<strong>Must not be a member of specified organization to register</strong>";
                                    }
                                    IsValidForContinue = false;
                                }
                            }
                        }
                    }
                    if (m.List.Count(ii => ii.PeopleId == PeopleId) > 1)
                    {
                        ModelState.AddModelError(foundname, "Person already in Pending Registration");
                        CancelText = "Regiser a different person";
                        if (setting.UseBootstrap)
                        {
                            NotFoundText = @"<strong>Person already in Pending Registration</strong>";
                        }
                        IsValidForContinue = false;
                    }
                }
                else if (count > 1)
                {
                    ModelState.AddModelError(foundname, "More than one match, sorry");
                    NotFoundText       = @"<strong>MORE THAN ONE MATCH</strong><br />
We have found more than one record that matches your information
This is an unexpected error and we don't know which one is you.
Please call the church to resolve this before we can complete your registration.";
                    IsValidForContinue = false;
                }
                else if (count == 0)
                {
                    ModelState.AddModelError(foundname, "record not found");
                    NotFoundText = @" <strong>RECORD NOT FOUND</strong><br />
                            We were not able to find you in our database. Please check the information you entered.
                            <ul>
                                <li>If everything looks good, select ""New Profile""</li>
                                <li>If you make a correction, select ""Search Again""</li>
                            </ul>";
                }
            }
            ValidateBirthdayRange(ModelState, i);
            IsValidForExisting = ModelState.IsValid;
        }
Exemplo n.º 7
0
        public void ValidateModelForNew(ModelStateDictionary ModelState, int i)
        {
            var dobname     = Parent.GetNameFor(mm => mm.List[i].DateOfBirth);
            var foundname   = Parent.GetNameFor(mm => mm.List[i].Found);
            var isnewfamily = whatfamily == 3;

            ValidBasic(ModelState, i);
            DateTime dt;

            if (RequiredDOB() && DateOfBirth.HasValue() && !Util.BirthDateValid(bmon, bday, byear, out dt))
            {
                ModelState.AddModelError(dobname, "birthday invalid");
            }
            else if (!birthday.HasValue && RequiredDOB())
            {
                ModelState.AddModelError(dobname, "birthday required");
            }
            if (birthday.HasValue && NoReqBirthYear() == false && birthday.Value.Year == Util.SignalNoYear)
            {
                ModelState.AddModelError(dobname, "BirthYear is required");
                IsValidForNew = false;
                return;
            }

            var minage = DbUtil.Db.Setting("MinimumUserAge", "16").ToInt();

            if (orgid == Util.CreateAccountCode && age < minage)
            {
                ModelState.AddModelError(dobname, "must be {0} to create account".Fmt(minage));
            }

            if (ComputesOrganizationByAge() && GetAppropriateOrg() == null)
            {
                ModelState.AddModelError(dobname, NoAppropriateOrgError);
            }

            ValidateBirthdayRange(ModelState, i);
            int n = 0;

            if (Phone.HasValue() && Phone.GetDigits().Length >= 10)
            {
                n++;
            }
            if (ShowAddress && HomePhone.HasValue() && HomePhone.GetDigits().Length >= 10)
            {
                n++;
            }

            if (RequiredPhone() && n == 0)
            {
                ModelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].Phone), "cell or home phone required");
            }

            if (HomePhone.HasValue() && HomePhone.GetDigits().Length > 20)
            {
                ModelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].HomePhone), "homephone too long");
            }

            if (EmailAddress.HasValue())
            {
                EmailAddress = EmailAddress.Trim();
            }
            if (!EmailAddress.HasValue() || !Util.ValidEmail(EmailAddress))
            {
                ModelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].EmailAddress), "Please specify a valid email address.");
            }
            if (isnewfamily)
            {
                if (!AddressLineOne.HasValue() && RequiredAddr())
                {
                    ModelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].AddressLineOne), "address required.");
                }
                if (RequiredZip() && AddressLineOne.HasValue())
                {
                    var addrok = City.HasValue() && State.HasValue();
                    if (ZipCode.HasValue())
                    {
                        addrok = true;
                    }
                    if (!addrok)
                    {
                        ModelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].ZipCode), "zip required (or \"na\")");
                    }

                    if (ModelState.IsValid && AddressLineOne.HasValue() &&
                        (Country == "United States" || !Country.HasValue()))
                    {
                        var r = AddressVerify.LookupAddress(AddressLineOne, AddressLineTwo, City, State, ZipCode);
                        if (r.Line1 != "error")
                        {
                            if (r.found == false)
                            {
                                ModelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].ZipCode), r.address + ", to skip address check, Change the country to USA, Not Validated");
                                ShowCountry = true;
                                return;
                            }
                            if (r.Line1 != AddressLineOne)
                            {
                                AddressLineOne = r.Line1;
                            }
                            if (r.Line2 != (AddressLineTwo ?? ""))
                            {
                                AddressLineTwo = r.Line2;
                            }
                            if (r.City != (City ?? ""))
                            {
                                City = r.City;
                            }
                            if (r.State != (State ?? ""))
                            {
                                State = r.State;
                            }
                            if (r.Zip != (ZipCode ?? ""))
                            {
                                ZipCode = r.Zip;
                            }
                        }
                    }
                }
            }

            if (!gender.HasValue && RequiredGender())
            {
                ModelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].gender), "Please specify gender");
            }
            if (!married.HasValue && RequiredMarital())
            {
                ModelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].married), "Please specify marital status");
            }

            if (MemberOnly())
            {
                ModelState.AddModelError(foundname, "Sorry, must be a member of church");
            }
            else if (org != null && setting.ValidateOrgIds.Count > 0)
            {
                ModelState.AddModelError(foundname, "Must be member of specified organization");
            }

            IsValidForNew      = ModelState.IsValid;
            IsValidForContinue = ModelState.IsValid;
        }