Ejemplo n.º 1
0
        private void ValidateBirthdate()
        {
            var      dobname = Parent.GetNameFor(mm => mm.List[Index].DateOfBirth);
            DateTime dt;

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

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

            if (orgid == Util.CreateAccountCode && age < minage)
            {
                modelState.AddModelError(dobname, $"must be {minage} to create account");
                Log("UnderAgeForAccount");
            }
            if (ComputesOrganizationByAge() && org == null)
            {
                modelState.AddModelError(dobname, NoAppropriateOrgError);
                Log("NoAppropriateOrg");
            }
        }
Ejemplo n.º 2
0
 public bool StillNeedBirthday()
 {
     if (RequiredDOB())
     {
         if (!DateOfBirth.HasValue() || byear == null)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
 public bool ShowOptionalBirthday()
 {
     return(!DateOfBirth.HasValue());
 }
Ejemplo n.º 4
0
        private void ValidateBasic()
        {
            if (!FirstName.HasValue())
            {
                modelState.AddModelError(Parent.GetNameFor(mm => mm.List[Index].FirstName), "first name required");
            }

            if (!LastName.HasValue())
            {
                modelState.AddModelError(Parent.GetNameFor(mm => mm.List[Index].LastName), "last name required");
            }

            var mindate = DateTime.Parse("1/1/1753");
            var HasOneOfThreeRequired = false;

            DateTime dt;

            if (DateOfBirth.HasValue() && !Util.BirthDateValid(bmon, bday, byear, out dt))
            {
                modelState.AddModelError(Parent.GetNameFor(mm => mm.List[Index].DateOfBirth), "birthday invalid");
            }

            if (BestBirthday.HasValue && BestBirthday < mindate)
            {
                modelState.AddModelError(Parent.GetNameFor(mm => mm.List[Index].DateOfBirth), "invalid date");
            }

            if (BestBirthday.HasValue && BestBirthday > mindate)
            {
                HasOneOfThreeRequired = true;
            }

            if (Util.ValidEmail(EmailAddress))
            {
                HasOneOfThreeRequired = true;
            }

            var d = Phone.GetDigits().Length;

            if (Phone.HasValue() && d >= 10)
            {
                HasOneOfThreeRequired = true;
            }

            if (d > 20)
            {
                modelState.AddModelError(Parent.GetNameFor(mm => mm.List[Index].Phone), "too many digits in phone");
            }

            if (!HasOneOfThreeRequired)
            {
                modelState.AddModelError("FORM", "we require one of valid birthdate, email or phone to find an Existing profile");
            }

            if (!Util.ValidEmail(EmailAddress) && (person == null || !Util.ValidEmail(person.EmailAddress)))
            {
                modelState.AddModelError(Parent.GetNameFor(mm => mm.List[Index].EmailAddress), "valid email required for registration confirmation");
            }

            if (Phone.HasValue() && d < 10)
            {
                modelState.AddModelError(Parent.GetNameFor(mm => mm.List[Index].Phone), "10+ digits required");
            }
            if (!modelState.IsValid)
            {
                Log("InvalidBasic");
            }
        }
Ejemplo n.º 5
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;
        }