Ejemplo n.º 1
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            CustomerEntities db = new CustomerEntities();
            var email           = db.客戶聯絡人.Where(x => x.Email == this.Email).FirstOrDefault();

            if (email != null)
            {
                yield return(new ValidationResult("Email欄位重複,請重新輸入", new string[] { "Email" }));
            }
        }
Ejemplo n.º 2
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            CustomerEntities db = new CustomerEntities();
            var existdata       = db.客戶聯絡人.Where(c => c.Email == Email);

            if (existdata.Any())
            {
                yield return(new ValidationResult(
                                 "同一個客戶下的聯絡人,其 Email 不能重複", new[] { "Email" }));
            }
        }