示例#1
0
        public ActionResult ValidateEmailAddress(string emailString)
        {
            try
            {
                using (var uow = ObjectFactory.GetInstance<IUnitOfWork>())
                {
                    EmailAddressDO emailAddressDO = _emailAddress.ConvertFromString(emailString, uow);
                    var ru = new RegexUtilities();
                    if (!(ru.IsValidEmailAddress(emailAddressDO.Address)))
                        return Json("Invalid email format");
                    else
                        return Json(true);
                }

            }
            catch (Exception ex)
            {
                return Json(ex.Message);
            }
        }
示例#2
0
 public void TestEmailUnderscore()
 {
     var ru = new RegexUtilities();
     Assert.True(ru.IsValidEmailAddress("*****@*****.**"));
 }
示例#3
0
 public void TestEmailDomainWithPeriod()
 {
     var ru = new RegexUtilities();
     Assert.True(ru.IsValidEmailAddress("*****@*****.**"));
 }
示例#4
0
 public void TestEmailNameWithDash()
 {
     var ru = new RegexUtilities();
     Assert.True(ru.IsValidEmailAddress("*****@*****.**"));
 }
示例#5
0
 public void TestIllegalSurroundingCharactersInvalid()
 {
     var ru = new RegexUtilities();
     Assert.False(ru.IsValidEmailAddress("'*****@*****.**'"));
 }
示例#6
0
        public ActionResult RunQuery(UserVM queryParams)
        {
            if (string.IsNullOrEmpty(queryParams.EmailAddress) && string.IsNullOrEmpty(queryParams.FirstName) &&
                string.IsNullOrEmpty(queryParams.LastName))
            {
                var jsonErrorResult = Json(_jsonPackager.Pack(new { Error = "Atleast one field is required" }));
                return jsonErrorResult;
            }
            if (queryParams.EmailAddress != null)
            {
                var ru = new RegexUtilities();

                if (!(ru.IsValidEmailAddress(queryParams.EmailAddress)))
                {
                    var jsonErrorResult = Json(_jsonPackager.Pack(new { Error = "Please provide valid email address" }));
                    return jsonErrorResult;
                }
            }
            using (var uow = ObjectFactory.GetInstance<IUnitOfWork>())
            {
                var query = uow.UserRepository.GetQuery();
                if (!String.IsNullOrWhiteSpace(queryParams.FirstName))
                    query = query.Where(u => u.FirstName.Contains(queryParams.FirstName));
                if (!String.IsNullOrWhiteSpace(queryParams.LastName))
                    query = query.Where(u => u.LastName.Contains(queryParams.LastName));
                if (!String.IsNullOrWhiteSpace(queryParams.EmailAddress))
                    query = query.Where(u => u.EmailAddress.Address.Contains(queryParams.EmailAddress));

                var matchedUsers = query.ToList();

                var jsonResult = Json(_jsonPackager.Pack(matchedUsers));

                jsonResult.MaxJsonLength = int.MaxValue;
                return jsonResult;
            }
        }
示例#7
0
 public static void ValidateEmailAddress(String emailAddress)
 {
     var ru = new RegexUtilities();
     if (!ru.IsValidEmailAddress(emailAddress))
         throw new ValidationException(new [] { new ValidationFailure("emailAddress", "Invalid email address: '" + emailAddress + "'")});
 }