Пример #1
0
        protected override void Validate()
        {
            if (string.IsNullOrEmpty(FirstName))
            {
                AddBrokenRule(UserBusinessRule.UserFirstNameRequired);
            }
            if (string.IsNullOrEmpty(LastName))
            {
                AddBrokenRule(UserBusinessRule.UserLastNameRequired);
            }
            if (HomePhone != null && !string.IsNullOrEmpty(HomePhone.Number) && !IsValidPhoneNumberLength(HomePhone.Number))
            {
                AddBrokenRule(ValueObjects.ValueObjectBusinessRule.PhoneNumberMinimumLength);
            }
            if (MobilePhone != null && !string.IsNullOrEmpty(MobilePhone.Number) && !IsValidPhoneNumberLength(MobilePhone.Number))
            {
                AddBrokenRule(ValueObjects.ValueObjectBusinessRule.PhoneNumberMinimumLength);
            }
            if (WorkPhone != null && !string.IsNullOrEmpty(WorkPhone.Number) && !IsValidPhoneNumberLength(WorkPhone.Number))
            {
                AddBrokenRule(ValueObjects.ValueObjectBusinessRule.PhoneNumberMinimumLength);
            }
            if (Email != null && !string.IsNullOrEmpty(Email.EmailId) && !IsValidEmail(Email.EmailId))
            {
                AddBrokenRule(UserBusinessRule.UserPrimaryEmailRequired);
            }
            /*Validates if all the secondary emails are valid*/
            if (SecondaryEmails != null)
            {
                foreach (Email email in SecondaryEmails)
                {
                    if (!string.IsNullOrEmpty(email.EmailId) && !IsValidEmail(email.EmailId))
                    {
                        AddBrokenRule(ValueObjects.ValueObjectBusinessRule.EmailIsInvalid);
                    }
                }
            }
            /*Validates if all the emails are valid*/
            if (Emails != null)
            {
                foreach (Email email in Emails)
                {
                    if (!string.IsNullOrEmpty(email.EmailId) && !IsValidEmail(email.EmailId))
                    {
                        AddBrokenRule(ValueObjects.ValueObjectBusinessRule.EmailIsInvalid);
                    }
                }
            }

            /*Validate Facebook URL:*/
            if (!IsValidUrl(facebookUrl, "facebook.com/"))
            {
                AddBrokenRule(UserBusinessRule.UserFacebookUrlInvalid);
            }
            /*Validate Twitter URL:*/
            if (!IsValidUrl(twitterUrl, "twitter.com/"))
            {
                AddBrokenRule(UserBusinessRule.UserTwitterUrlInvalid);
            }
            /*Validate Google+ URL:*/
            if (!IsValidUrl(googlePlusUrl, "plus.google.com/"))
            {
                AddBrokenRule(UserBusinessRule.UserGooglePlusUrlInvalid);
            }
            /*Validate LinkedIn URL:*/
            if (!IsValidUrl(linkedInUrl, "linkedin.com/"))
            {
                AddBrokenRule(UserBusinessRule.UserLinkedInUrlInvalid);
            }
            /*Validate Blog URL:*/
            if (BlogUrl != null && !string.IsNullOrEmpty(BlogUrl.URL) && !BlogUrl.IsValidURL())
            {
                AddBrokenRule(UserBusinessRule.UserBlogInUrlInvalid);
            }
            /*Validate Web URL:*/
            if (WebsiteUrl != null && !string.IsNullOrEmpty(WebsiteUrl.URL) && !WebsiteUrl.IsValidURL())
            {
                AddBrokenRule(UserBusinessRule.UserWebURLInvalid);
            }
        }
Пример #2
0
        protected override void Validate()
        {
            if (string.IsNullOrEmpty(AccountName))
            {
                AddBrokenRule(AccountBusinessRule.AccountNameRequired);
            }

            if (string.IsNullOrEmpty(FirstName))
            {
                AddBrokenRule(AccountBusinessRule.AccountFirstNameRequired);
            }

            if (string.IsNullOrEmpty(LastName))
            {
                AddBrokenRule(AccountBusinessRule.AccountLastNameRequired);
            }

            if (HomePhone != null && !string.IsNullOrEmpty(HomePhone.Number) && !IsValidPhoneNumberLength(HomePhone.Number))
            {
                AddBrokenRule(ValueObjects.ValueObjectBusinessRule.PhoneNumberMinimumLength);
            }

            if (MobilePhone != null && !string.IsNullOrEmpty(MobilePhone.Number) && !IsValidPhoneNumberLength(MobilePhone.Number))
            {
                AddBrokenRule(ValueObjects.ValueObjectBusinessRule.PhoneNumberMinimumLength);
            }

            if (WorkPhone != null && !string.IsNullOrEmpty(WorkPhone.Number) && !IsValidPhoneNumberLength(WorkPhone.Number))
            {
                AddBrokenRule(ValueObjects.ValueObjectBusinessRule.PhoneNumberMinimumLength);
            }

            if (!string.IsNullOrEmpty(Email.EmailId) && !IsValidEmail(Email.EmailId))
            {
                AddBrokenRule(AccountBusinessRule.AccountPrimaryEmailRequired);
            }

            foreach (Address address in Addresses)
            {
                if (!address.IsValidCountry())
                {
                    AddBrokenRule(ValueObjectBusinessRule.CountryInAddressRequired);
                }
                if (!address.IsValidState())
                {
                    AddBrokenRule(ValueObjectBusinessRule.StateInAddressRequired);
                }
                if (address.Country.Code == "US" && !string.IsNullOrEmpty(address.ZipCode) && !IsValidUSZipCode(address.ZipCode))
                {
                    AddBrokenRule(ValueObjectBusinessRule.ZipCodeFormatInvalid);
                }
                if (address.Country.Code == "CA" && !string.IsNullOrEmpty(address.ZipCode) && !IsValidCanadianPostalCode(address.ZipCode))
                {
                    AddBrokenRule(ValueObjectBusinessRule.PostalCodeFormatInvalid);
                }
            }

            //Validates if all the secondary emails are valid
            if (SecondaryEmails != null)
            {
                foreach (Email email in SecondaryEmails)
                {
                    if (!string.IsNullOrEmpty(Email.EmailId) && !IsValidEmail(email.EmailId))
                    {
                        AddBrokenRule(ValueObjects.ValueObjectBusinessRule.EmailIsInvalid);
                    }
                }
            }
            //Validate Facebook URL:
            //if (FacebookUrl !=null && !string.IsNullOrEmpty(FacebookUrl.URL) && (!FacebookUrl.IsValidURL() || !this.FacebookUrl.URL.ToLower().Contains("facebook.com")))
            if (facebookUrl != null && !string.IsNullOrEmpty(facebookUrl.URL) && !IsFacebookURLValid(facebookUrl))
            {
                AddBrokenRule(AccountBusinessRule.AccountFacebookUrlInvalid);
            }

            //Validate Twitter URL:
            if (twitterUrl != null && !string.IsNullOrEmpty(twitterUrl.URL) && !IsTwitterURLValid(twitterUrl))
            {
                AddBrokenRule(AccountBusinessRule.AccountTwitterUrlInvalid);
            }

            //Validate Google+ URL:
            if (googlePlusUrl != null && !string.IsNullOrEmpty(googlePlusUrl.URL) && !IsGooglePlusURLValid(googlePlusUrl))
            {
                AddBrokenRule(AccountBusinessRule.AccountGooglePlusUrlInvalid);
            }

            //Validate LinkedIn URL:
            if (linkedInUrl != null && !string.IsNullOrEmpty(linkedInUrl.URL) && !IsLinkedInURLValid(linkedInUrl))
            {
                AddBrokenRule(AccountBusinessRule.AccountLinkedInUrlInvalid);
            }

            //Validate Blog URL:
            if (BlogUrl != null && !string.IsNullOrEmpty(BlogUrl.URL) && !BlogUrl.IsValidURL())
            {
                AddBrokenRule(AccountBusinessRule.AccountBlogInUrlInvalid);
            }

            //Validate Web URL:
            if (WebsiteUrl != null && !string.IsNullOrEmpty(WebsiteUrl.URL) && !WebsiteUrl.IsValidURL())
            {
                AddBrokenRule(AccountBusinessRule.AccountWebURLInvalid);
            }
        }
Пример #3
0
 /// <summary>
 /// Validates Accounts model
 /// </summary>
 protected override void Validate()
 {
     if (string.IsNullOrEmpty(AccountName))
     {
         AddBrokenRule(AccountBusinessRule.AccountNameRequired);
     }
     if (string.IsNullOrEmpty(FirstName))
     {
         AddBrokenRule(AccountBusinessRule.AccountFirstNameRequired);
     }
     if (string.IsNullOrEmpty(LastName))
     {
         AddBrokenRule(AccountBusinessRule.AccountLastNameRequired);
     }
     if (HomePhone != null && !string.IsNullOrEmpty(HomePhone.Number) && !IsValidPhoneNumberLength(HomePhone.Number))
     {
         AddBrokenRule(ValueObjects.ValueObjectBusinessRule.PhoneNumberMinimumLength);
     }
     if (MobilePhone != null && !string.IsNullOrEmpty(MobilePhone.Number) && !IsValidPhoneNumberLength(MobilePhone.Number))
     {
         AddBrokenRule(ValueObjects.ValueObjectBusinessRule.PhoneNumberMinimumLength);
     }
     if (WorkPhone != null && !string.IsNullOrEmpty(WorkPhone.Number) && !IsValidPhoneNumberLength(WorkPhone.Number))
     {
         AddBrokenRule(ValueObjects.ValueObjectBusinessRule.PhoneNumberMinimumLength);
     }
     if (!string.IsNullOrEmpty(Email.EmailId) && !IsValidEmail(Email.EmailId))
     {
         AddBrokenRule(AccountBusinessRule.AccountPrimaryEmailRequired);
     }
     if (string.IsNullOrEmpty(DomainURL))
     {
         AddBrokenRule(AccountBusinessRule.AccountDomainNameRequired);
     }
     if (!IsDomainNameValid(DomainURL))
     {
         AddBrokenRule(AccountBusinessRule.AccountDomainNameInvalid);
     }
     if (string.IsNullOrEmpty(HelpURL))
     {
         AddBrokenRule(AccountBusinessRule.HelpURLIsRequired);
     }
     if (!IsValidURL())
     {
         AddBrokenRule(AccountBusinessRule.HelpURLIsInvalid);
     }
     //Validates if all the secondary emails are valid
     if (SecondaryEmails != null)
     {
         foreach (Email email in SecondaryEmails)
         {
             if (!string.IsNullOrEmpty(Email.EmailId) && !IsValidEmail(email.EmailId))
             {
                 AddBrokenRule(ValueObjects.ValueObjectBusinessRule.EmailIsInvalid);
             }
         }
     }
     //Validate Facebook URL:
     if (facebookUrl != null && !string.IsNullOrEmpty(facebookUrl.URL) && !ValidateURL(facebookUrl, "facebook.com/"))
     {
         AddBrokenRule(AccountBusinessRule.AccountFacebookUrlInvalid);
     }
     //Validate Twitter URL:
     if (twitterUrl != null && !string.IsNullOrEmpty(twitterUrl.URL) && !ValidateURL(twitterUrl, "twitter.com/"))
     {
         AddBrokenRule(AccountBusinessRule.AccountTwitterUrlInvalid);
     }
     //Validate Google+ URL:
     if (googlePlusUrl != null && !string.IsNullOrEmpty(googlePlusUrl.URL) && !ValidateURL(googlePlusUrl, "plus.google.com/"))
     {
         AddBrokenRule(AccountBusinessRule.AccountGooglePlusUrlInvalid);
     }
     //Validate LinkedIn URL:
     if (linkedInUrl != null && !string.IsNullOrEmpty(linkedInUrl.URL) && !ValidateURL(linkedInUrl, "linkedin.com/"))
     {
         AddBrokenRule(AccountBusinessRule.AccountLinkedInUrlInvalid);
     }
     //Validate Blog URL:
     if (BlogUrl != null && !string.IsNullOrEmpty(BlogUrl.URL) && !BlogUrl.IsValidURL())
     {
         AddBrokenRule(AccountBusinessRule.AccountBlogInUrlInvalid);
     }
     //Validate Web URL:
     if (WebsiteUrl != null && !string.IsNullOrEmpty(WebsiteUrl.URL) && !WebsiteUrl.IsValidURL())
     {
         AddBrokenRule(AccountBusinessRule.AccountWebURLInvalid);
     }
 }
Пример #4
0
        protected override void Validate()
        {
            //if (!string.IsNullOrEmpty(ImageUrl) && !this.IsValidImageType())
            //{
            //        AddBrokenRule(ContactBusinessRule.ContactImageTypeInvalid);
            //}

            if (WorkPhone != null && !string.IsNullOrEmpty(WorkPhone.Number) && !IsValidPhoneNumberLength(WorkPhone.Number))
            {
                AddBrokenRule(ValueObjects.ValueObjectBusinessRule.PhoneNumberMinimumLength);
            }

            if (!string.IsNullOrEmpty(Email.EmailId) && !IsValidEmail(Email.EmailId))
            {
                AddBrokenRule(ContactBusinessRule.ContactPrimaryEmailRequired);
            }

            foreach (Address address in Addresses)
            {
                if (!address.IsValidCountry())
                {
                    AddBrokenRule(ValueObjectBusinessRule.CountryInAddressRequired);
                }
                if (!address.IsValidState())
                {
                    AddBrokenRule(ValueObjectBusinessRule.StateInAddressRequired);
                }
                if (address.Country.Code == "US" && !string.IsNullOrEmpty(address.ZipCode) && !IsValidUSZipCode(address.ZipCode))
                {
                    AddBrokenRule(ValueObjectBusinessRule.ZipCodeFormatInvalid);
                }
                if (address.Country.Code == "CA" && !string.IsNullOrEmpty(address.ZipCode) && !IsValidCanadianPostalCode(address.ZipCode))
                {
                    AddBrokenRule(ValueObjectBusinessRule.PostalCodeFormatInvalid);
                }
            }

            //If "LastContacted" is entered manually by the user then the following validation is valid
            if (LastContacted > DateTime.Today)
            {
                AddBrokenRule(ContactBusinessRule.ContactLastContactedDateInvalid);
            }

            //Validates if all the secondary emails are valid
            if (SecondaryEmails != null)
            {
                foreach (Email email in SecondaryEmails)
                {
                    if (!string.IsNullOrEmpty(Email.EmailId) && !IsValidEmail(email.EmailId))
                    {
                        AddBrokenRule(ValueObjects.ValueObjectBusinessRule.EmailIsInvalid);
                    }
                }
            }
            //Validate Facebook URL:
            //if (FacebookUrl !=null && !string.IsNullOrEmpty(FacebookUrl.URL) && (!FacebookUrl.IsValidURL() || !this.FacebookUrl.URL.ToLower().Contains("facebook.com")))
            if (facebookUrl != null && !string.IsNullOrEmpty(facebookUrl.URL) && !IsFacebookURLValid(facebookUrl))
            {
                AddBrokenRule(ContactBusinessRule.ContactFacebookUrlInvalid);
            }

            //Validate Twitter URL:
            if (twitterUrl != null && !string.IsNullOrEmpty(twitterUrl.URL) && !IsTwitterURLValid(twitterUrl))
            {
                AddBrokenRule(ContactBusinessRule.ContactTwitterUrlInvalid);
            }

            //Validate Google+ URL:
            if (googlePlusUrl != null && !string.IsNullOrEmpty(googlePlusUrl.URL) && !IsGooglePlusURLValid(googlePlusUrl))
            {
                AddBrokenRule(ContactBusinessRule.ContactGooglePlusUrlInvalid);
            }

            //Validate LinkedIn URL:
            if (linkedInUrl != null && !string.IsNullOrEmpty(linkedInUrl.URL) && !IsLinkedInURLValid(linkedInUrl))
            {
                AddBrokenRule(ContactBusinessRule.ContactLinkedInUrlInvalid);
            }

            //Validate Blog URL:
            if (BlogUrl != null && !string.IsNullOrEmpty(BlogUrl.URL) && !BlogUrl.IsValidURL())
            {
                AddBrokenRule(ContactBusinessRule.ContactBlogInUrlInvalid);
            }

            //Validate Web URL:
            if (WebsiteUrl != null && !string.IsNullOrEmpty(WebsiteUrl.URL) && !WebsiteUrl.IsValidURL())
            {
                AddBrokenRule(ContactBusinessRule.ContactWebURLInvalid);
            }
        }