Пример #1
0
        public bool Process(String UserID, List <String> ReferalUser)
        {
            user tUser = (from m in DB.users where m.email == UserID select m).FirstOrDefault();

            if (tUser == null)
            {
                return(false);
            }

            foreach (string treferer in ReferalUser)
            {
                if (Regex.IsMatch(treferer, @"\d"))
                {
                    //Call Exotel to confirm number.
                    SmsReferer(treferer);
                }
                else
                {
                    System.ComponentModel.DataAnnotations.EmailAddressAttribute tAddress = new System.ComponentModel.DataAnnotations.EmailAddressAttribute();

                    if (tAddress.IsValid(treferer))
                    {
                        emailReferer(treferer);
                    }
                }
            }

            return(true);
        }
Пример #2
0
 public HttpResult Register(User item)
 {
     if (item == null || string.IsNullOrEmpty(item.UserName) || string.IsNullOrEmpty(item.Password) || string.IsNullOrEmpty(item.Email))
     {
         return(new HttpResult {
             RetCode = 1, Message = "User Name, Email or Password can't be empty!"
         });
     }
     else if (repo.Exists(item.UserName))
     {
         return(new HttpResult {
             RetCode = 1, Message = string.Format("User with name [{0}] is already existing, choose another name.", item.UserName)
         });
     }
     else
     {
         var foo = new System.ComponentModel.DataAnnotations.EmailAddressAttribute();
         if (!foo.IsValid(item.Email))
         {
             return(new HttpResult {
                 RetCode = 1, Message = "The Email address is not valid!"
             });
         }
         else
         {
             repo.Add(item);
             return(new HttpResult {
                 RetCode = 0, Message = "Registration succeed!"
             });
         }
     }
 }
Пример #3
0
        /// <summary>
        /// When overridden in a derived class, performs validation checks on a value.
        /// Validates if user use proper address email.
        /// </summary>
        /// <param name="value">The value from the binding target to check.</param>
        /// <param name="cultureInfo">The culture to use in this rule.</param>
        /// <returns>
        /// A <see cref="T:System.Windows.Controls.ValidationResult" /> object.
        /// </returns>
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            var  emailAttrib = new System.ComponentModel.DataAnnotations.EmailAddressAttribute();
            bool result;

            result = emailAttrib.IsValid(value.ToString());

            return(new ValidationResult(result, Resources.Strings.InProperEmailFormat));
        }
Пример #4
0
        public bool IsEmailValid(string email)
        {
            if (string.IsNullOrWhiteSpace(email))
            {
                return(false);
            }

            System.ComponentModel.DataAnnotations.EmailAddressAttribute attr = new System.ComponentModel.DataAnnotations.EmailAddressAttribute();
            return(attr.IsValid(email));
        }
Пример #5
0
        public bool EmailAddressInvalid(AddPatientRequest request, ref PdrValidationResult result)
        {
            var emailAddressAttribute = new System.ComponentModel.DataAnnotations.EmailAddressAttribute();

            if (!emailAddressAttribute.IsValid(request.Email))
            {
                result.PassedValidation = false;
                result.Errors.Add("Email must be a valid email address");
                return(false);
            }

            return(true);
        }
Пример #6
0
        public void Email_Property_EmailEmail_Validation_Invalid()
        {
            // Arrange
            var emailChecker = new System.ComponentModel.DataAnnotations.EmailAddressAttribute();
            var email        = new Email();
            var value        = "test";

            // Act
            email.EmailAddress = value;

            // Assert
            Assert.IsFalse(emailChecker.IsValid(email.EmailAddress));
            Assert.IsNotNull(email.EmailAddress);
            Assert.AreEqual(value, email.EmailAddress);
        }
Пример #7
0
        public static bool IsEmail(string email)
        {
            try
            {
                //var addr = new System.Net.Mail.MailAddress(email);
                //return addr.Address == email;

                var foo = new System.ComponentModel.DataAnnotations.EmailAddressAttribute();
                return(foo.IsValid(email));
            }
            catch
            {
                return(false);
            }
        }
Пример #8
0
        public static bool IsValid(this Member member)
        {
            bool retVal = true;

            retVal |= !String.IsNullOrWhiteSpace(member.Name);
            retVal |= !String.IsNullOrWhiteSpace(member.LastName);
            retVal |= DateTime.Now.Year - member.Birth.Year < 150;

            var x         = new MemberDataModel();
            var ISTATCode = x.GetISTATCode(member.BirthLocality);

            if (retVal |= !string.IsNullOrWhiteSpace(ISTATCode))
            {
                retVal |= CodiceFiscale.ControlloFormaleOK(member.FiscalCode, member.Name, member.LastName, member.Birth, member.Gender.ToString("G")[0], ISTATCode);
            }
            if (member.Address != null)
            {
                if (!string.IsNullOrWhiteSpace(member.Address.FormattedAddress))
                {
                    if (!member.Address.IsServiceValidated())
                    {
                        member.Address.GoogleMapValidate(@"AIzaSyCLTiM7knDkCFqBIbafAlL_96ONIROU-Eo");
                    }
                }
                else
                {
                    retVal |= false;
                }
            }
            var mailAttrib = new System.ComponentModel.DataAnnotations.EmailAddressAttribute();


            retVal |= String.IsNullOrEmpty(member.Mail) || mailAttrib.IsValid(member.Mail);
            retVal |= !String.IsNullOrWhiteSpace(member.Phone);

            // no check HealthCertificate
            retVal |= member.Status != null;
            // no check Affiliations

            return(retVal);
        }
Пример #9
0
        /// <summary>
        /// 驗證Email格式_2017/08/25
        /// </summary>
        /// <param name="mailAddress">待驗證的電子郵件位址</param>
        /// <returns>是否為電子郵件格式</returns>
        public static bool CheckEmailAddress(string mailAddress)
        {
            var mailAttr = new System.ComponentModel.DataAnnotations.EmailAddressAttribute();

            return(mailAttr.IsValid(mailAddress));
        }
Пример #10
0
        private bool CheckEmail(string email)
        {
            var mailValidater = new System.ComponentModel.DataAnnotations.EmailAddressAttribute();

            return(mailValidater.IsValid(email));
        }
Пример #11
0
        public static bool IsValid(this Member member, string property)
        {
            bool retVal = true;

            switch (property)
            {
            case "Name":
                retVal |= !String.IsNullOrWhiteSpace(member.Name);
                break;

            case "LastName":
                retVal |= !String.IsNullOrWhiteSpace(member.LastName);
                break;

            case "Birth":
                retVal |= DateTime.Now.Year - member.Birth.Year < 150 && DateTime.Now.Year - member.Birth.Year > 0;
                break;

            case "BirthLocality":
                var    bmdm      = new MemberDataModel();
                string ISTATCode = bmdm.GetISTATCode(member.BirthLocality);
                retVal |= !string.IsNullOrWhiteSpace(ISTATCode);
                break;

            case "FiscalCode":
                var fmdm       = new MemberDataModel();
                var ISTATCode2 = fmdm.GetISTATCode(member.BirthLocality);
                if (retVal |= !string.IsNullOrWhiteSpace(ISTATCode2))
                {
                    retVal |= CodiceFiscale.ControlloFormaleOK(member.FiscalCode, member.Name, member.LastName, member.Birth, member.Gender.ToString("G")[0], ISTATCode2);
                }
                break;

            case "Address":
                if (member.Address != null)
                {
                    if (!string.IsNullOrWhiteSpace(member.Address.FormattedAddress))
                    {
                        if (!member.Address.IsServiceValidated())
                        {
                            member.Address.GoogleMapValidate(@"AIzaSyCLTiM7knDkCFqBIbafAlL_96ONIROU-Eo");
                        }
                    }
                    else
                    {
                        retVal |= false;
                    }
                }
                break;

            case "Mail":
                var mailAttrib = new System.ComponentModel.DataAnnotations.EmailAddressAttribute();
                retVal |= String.IsNullOrEmpty(member.Mail) || mailAttrib.IsValid(member.Mail);
                break;

            case "Phone":
                retVal |= !String.IsNullOrWhiteSpace(member.Phone);
                break;

            case "Status":
                // no check HealthCertificate
                retVal |= member.Status != null;
                break;
            }
            return(retVal);
        }
Пример #12
0
        public static bool CheckEmailAddress(string email)
        {
            var emailChecker = new System.ComponentModel.DataAnnotations.EmailAddressAttribute();

            return(emailChecker.IsValid(email));
        }
Пример #13
0
        public static PropertyType ToPropertyType(this string property)
        {
            // parse JSON
            try
            {
                dynamic obj = JsonConvert.DeserializeObject(property);

                if (obj != null)
                {
                    Type t = obj.GetType();
                    if (t.Name == "JObject" || t.Name == "JArray")
                    {
                        return(PropertyType.Json);
                    }
                }
            }
            catch
            {
            }

            // parse int
            int i;

            if (int.TryParse(property, out i))
            {
                return(PropertyType.Int);
            }

            // parse double
            double d;

            if (double.TryParse(property, out d))
            {
                return(PropertyType.Double);
            }

            // parse boolean
            bool b;

            if (bool.TryParse(property, out b))
            {
                return(PropertyType.Bool);
            }

            // parse email
            System.ComponentModel.DataAnnotations.EmailAddressAttribute emailAttr = new System.ComponentModel.DataAnnotations.EmailAddressAttribute();
            if (emailAttr.IsValid(property))
            {
                return(PropertyType.Email);
            }

            // parse uri
            try
            {
                Uri uri;

                if (Uri.TryCreate(property, UriKind.Absolute, out uri))
                {
                    return(PropertyType.Url);
                }
            }
            catch
            {
            }

            Regex    rgxDateTime = new Regex(@"^(0?[1-9]|1[012])(:[0-5]\d) [APap][mM]$", RegexOptions.IgnoreCase);
            DateTime dt;

            if (rgxDateTime.IsMatch(property))
            {
                if (DateTime.TryParse(property, out dt))
                {
                    return(PropertyType.Time);
                }
            }

            TimeSpan ts;

            if (TimeSpan.TryParse(property, out ts))
            {
                return(PropertyType.Time);
            }

            rgxDateTime = new Regex(@"^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$");
            rgxDateTime.IsMatch(property);
            if (property.Length >= 8 && DateTime.TryParse(property, out dt))
            {
                if (dt.TimeOfDay != TimeSpan.Zero)
                {
                    return(PropertyType.Datetime);
                }
                return(PropertyType.Date);
            }

            // default - string type
            return(property.Contains(Environment.NewLine) ? PropertyType.Textarea : PropertyType.String);
        }
Пример #14
0
        public string this[string columnName] {
            get {
                string result = null;
                bool   retVal = true;
                switch (columnName)
                {
                case "Name":
                    retVal |= !String.IsNullOrWhiteSpace(Name);
                    break;

                case "LastName":
                    retVal |= !String.IsNullOrWhiteSpace(LastName);
                    break;

                case "Birth":
                    retVal |= DateTime.Now.Year - Birth.Year < 150 && DateTime.Now.Year - Birth.Year > 0;
                    break;

                case "BirthLocality":
                    //var bmdm = new MemberDataModel();
                    //var ISTATCode = bmdm.GetISTATCode(BirthLocality);
                    //retVal |= !string.IsNullOrWhiteSpace(ISTATCode);
                    break;

                case "FiscalCode":
                    //var fmdm = new MemberDataModel();
                    //var ISTATCode2 = fmdm.GetISTATCode(BirthLocality);
                    //if (retVal |= !string.IsNullOrWhiteSpace(ISTATCode2))
                    //    retVal |= CodiceFiscale.ControlloFormaleOK(FiscalCode, Name, LastName, Birth, Gender.ToString("G")[0], ISTATCode);
                    break;

                case "Address":
                    //if (Address != null)
                    //    if (!string.IsNullOrWhiteSpace(Address.FormattedAddress))
                    //    {
                    //        if (!Address.IsServiceValidated())
                    //        {
                    //            Address.GoogleMapValidate(@"AIzaSyCLTiM7knDkCFqBIbafAlL_96ONIROU-Eo");
                    //        }
                    //    }
                    //    else retVal |= false;
                    break;

                case "Mail":
                    var mailAttrib = new System.ComponentModel.DataAnnotations.EmailAddressAttribute();
                    retVal |= String.IsNullOrEmpty(Mail) || mailAttrib.IsValid(Mail);
                    break;

                case "Phone":
                    retVal |= !String.IsNullOrWhiteSpace(Phone);
                    result  = "Age must not be less than 0 or greater than 150.";
                    break;

                case "Status":
                    // no check HealthCertificate
                    retVal |= Status != null;
                    break;
                }

                return(result);
            }
        }