public ValidationResult Validate(OutlookContext context, int id, string email)
        {
            Addresses.Clear();
            if (Emails.Length == 0)
            {
                return(new ValidationResult("Error: No addresses provided!"));
            }
            if (GroupName.Length == 0)
            {
                return(new ValidationResult("Error: No Group Name provided!"));
            }
            if (GroupName.StartsWith("g:"))
            {
                return(new ValidationResult("Error: Invalid Group Name, start with 'g:' is not allowed"));
            }
            if (GroupName.Contains(";"))
            {
                return(new ValidationResult("Error: Invalid Group Name, using ';' is not allowed"));
            }
            if (context.Groups.Where(g => g.GroupName == GroupName && g.OwnerId == id).ToList().Count > 0)
            {
                return(new ValidationResult("Error: Invalid Group Name, you have already group with the same name"));
            }
            string[] EmailsTab = Emails.Split(';');
            (bool dis1, ValidationResult v1) = CheckExistence(context, id, email, EmailsTab, "Error in group members", 0);
            if (v1 != ValidationResult.Success)
            {
                return(v1);
            }


            return(ValidationResult.Success);
        }
示例#2
0
        private void GroupDialogMultiAdd_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.Cancel)
            {
                return;
            }

            var msg = String.Empty;

            if (GroupName.Contains(Group.GroupTextDivider) || GroupName.Contains(","))
            {
                msg = String.Format("A group name can not contain a {0} or a ,", Group.GroupTextDivider);
            }
            else if (GroupCount < 1)
            {
                msg = "Need to pick how many groups to create.";
            }

            if (String.IsNullOrEmpty(msg))
            {
                return;
            }

            MessageBox.Show(msg, @"Bad Group Name or Count", MessageBoxButtons.OK);
            e.Cancel = true;
        }