Exemplo n.º 1
0
        private bool IsValid()
        {
            _BrokenRules.List.Clear();
            bool result = true;

            if (_Name.Trim() == string.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Name; cannot be empty.");
                _BrokenRules.List.Add(rule);
            }
            if (_Description.Trim() == string.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Description; cannot be empty.");
                _BrokenRules.List.Add(rule);
            }
            if (_Name.Length > 20)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Name; cannot be more than 20 characters.");
                _BrokenRules.List.Add(rule);
            }

            return(result);
        }
Exemplo n.º 2
0
        private Boolean IsValid()
        {
            _BrokenRules.List.Clear();
            Boolean result = true;

            if (_UserName == null || _UserName.Trim() == String.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("User Name cannot be empty.");
                _BrokenRules.List.Add(rule);
            }
            if (_Email == null || _Email.Trim() == String.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Email cannot be empty");
                _BrokenRules.List.Add(rule);
            }
            if (_Password == null || _Password.Trim() == String.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Password cannot be empty.");
                _BrokenRules.List.Add(rule);
            }
            if (IsStrongPw(_Password) == false)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Password is not strong enough");
                _BrokenRules.List.Add(rule);
            }
            if (_UserName == null || _UserName.Length > 20)
            {
                result = false;
                BrokenRule rule = new BrokenRule("User Name must be less than 20 characters.");
                _BrokenRules.List.Add(rule);
            }
            if (_Password == null || _Password.Length > 20)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Password must be less than 20 characters.");
                _BrokenRules.List.Add(rule);
            }

            String pattern    = @"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";
            Regex  expression = new Regex(pattern);

            if (expression.IsMatch(_Email) == false)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid email format.");
                _BrokenRules.List.Add(rule);
            }

            return(result);
        }
Exemplo n.º 3
0
        private bool IsValid()
        {
            _BrokenRules.List.Clear();
            bool result = true;


            if (_Name == null || _Name.Trim() == string.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Department Name cannot be empty.");
                _BrokenRules.List.Add(rule);
            }
            return(result);
        }
Exemplo n.º 4
0
        private Boolean IsValid()
        {
            _BrokenRules.List.Clear();
            bool result = true;

            if (_FirstName == null || _FirstName == string.Empty)

            {
                result = false;
                BrokenRule rule = new BrokenRule("First NAme CANNOT be Empty");
                _BrokenRules.List.Add(rule);
            }
            if (_LastName == null || _LastName == string.Empty)

            {
                result = false;
                BrokenRule rule = new BrokenRule("Last NAme CANNOT be Empty");
                _BrokenRules.List.Add(rule);
            }

            if (_Email == null || _Email == string.Empty)

            {
                result = false;
                BrokenRule rule = new BrokenRule("Email CANNOT be Empty");
                _BrokenRules.List.Add(rule);
            }


            if (_Password == null || _Password == string.Empty)

            {
                result = false;
                BrokenRule rule = new BrokenRule("Password CANNOT be Null");
                _BrokenRules.List.Add(rule);
            }

            if (_DepartmentId == null || _DepartmentId == Guid.Empty)

            {
                result = false;
                BrokenRule rule = new BrokenRule("Please select a department");
                _BrokenRules.List.Add(rule);
            }
            return(result);
        }
Exemplo n.º 5
0
        private Boolean IsValid()
        {
            Boolean result = true;

            _BrokenRules.List.Clear();

            if (_CategoryID == Guid.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid ID. ID cannot be empty");
                _BrokenRules.List.Add(rule);
            }
            if (_Name == null || _Name.Trim() == String.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Name. Name cannot be empty.");
                _BrokenRules.List.Add(rule);
            }
            if (_Name == null || _Name.Length > 20)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Name. Name cannot be greater than 20 characters.");
                _BrokenRules.List.Add(rule);
            }
            if (_Description == null || _Description.Trim() == String.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Description. Description cannot be empty.");
                _BrokenRules.List.Add(rule);
            }
            if (_Description == null || _Description.Length > 20)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Description. Description cannot be grater than 20 characters");
                _BrokenRules.List.Add(rule);
            }
            if (_Price == 0)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Price. Price cannot be empty.");
                _BrokenRules.List.Add(rule);
            }

            return(result);
        }
Exemplo n.º 6
0
        private Boolean IsValid()
        {
            Boolean result = true;

            _BrokenRules.List.Clear();

            if (_UserId == Guid.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid ID. ID cannot be empty");
                _BrokenRules.List.Add(rule);
            }
            if (_Title == null || _Title.Trim() == String.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid. Title cannot be empty.");
                _BrokenRules.List.Add(rule);
            }
            if (_Title == null || _Title.Length > 20)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid. Title cannot be greater than 20 characters.");
                _BrokenRules.List.Add(rule);
            }
            if (_Description == null || _Description.Trim() == String.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Description. Description cannot be empty.");
                _BrokenRules.List.Add(rule);
            }
            if (_Description == null || _Description.Length > 20)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Description. Description cannot be grater than 20 characters");
                _BrokenRules.List.Add(rule);
            }
            if (_ImagePath == null)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid. Photo cannot be null.");
                _BrokenRules.List.Add(rule);
            }

            return(result);
        }
Exemplo n.º 7
0
        private Boolean IsValid()
        {
            Boolean result = true;

            _BrokenRules.List.Clear();

            if (_FirstName == string.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid First Name. Cannot be empty");
                _BrokenRules.List.Add(rule);
            }
            if (_LastName == string.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Last Name. Cannot be empty");
                _BrokenRules.List.Add(rule);
            }

            return(result);
        }
Exemplo n.º 8
0
        private bool IsValid()
        {
            _BrokenRules.List.Clear();
            bool result = true;

            if (_FirstName.Trim() == string.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid First Name; cannot be empty.");
                _BrokenRules.List.Add(rule);
            }
            if (_LastName.Trim() == string.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Last Name; cannot be empty.");
                _BrokenRules.List.Add(rule);
            }
            if (_FirstName.Length > 20)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid First Name; cannot be more than 20 characters.");
                _BrokenRules.List.Add(rule);
            }
            if (_LastName.Length > 20)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Last Name; cannot be more than 20 characters.");
                _BrokenRules.List.Add(rule);
            }
            if (_FirstName.Trim().Length < 1)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid First Name; cannot be empty.");
                _BrokenRules.List.Add(rule);
            }
            if (_LastName.Trim().Length < 1)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Last Name; cannot be empty.");
                _BrokenRules.List.Add(rule);
            }
            if (_Email == String.Empty)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Email; cannot be empty.");
                _BrokenRules.List.Add(rule);
            }

            string pattern    = @"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";
            Regex  expression = new Regex(pattern);

            if (expression.IsMatch(_Email) == false)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Email Format");
                _BrokenRules.List.Add(rule);
            }
            if (_Password == null)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Invalid Password; cannot be empty.");
                _BrokenRules.List.Add(rule);
            }
            if (IsStrongPassword(_Password) == false)
            {
                result = false;
                BrokenRule rule = new BrokenRule("Weak Password");
                _BrokenRules.List.Add(rule);
            }

            return(result);
        }