Пример #1
0
        public ValidationResult ValidateUserGroupName(string userGroupName, string originalGroupName)
        {
            // This web service in turns call a WCF service which resides on the same or different systems.

            ValidationResult result = new ValidationResult();

            if (String.IsNullOrEmpty(userGroupName))
            {
                result.Success   = false;
                result.ErrorCode = -1;
                result.ErrorText = ValidationErrors.UserGroupCannotBeEmpty;
                return(result);
            }

            UserManagementController controller = new UserManagementController();

            if (controller.ExistsUsergroup(userGroupName) && !userGroupName.Equals(originalGroupName))
            {
                result.Success   = false;
                result.ErrorCode = -1;
                result.ErrorText = String.Format(ValidationErrors.UserGroupAlreadyExists, userGroupName);;
                return(result);
            }
            else
            {
                result.Success = true;
            }

            return(result);
        }
Пример #2
0
        protected override bool OnServerSideEvaluate()
        {
            String groupName         = GetControlValidationValue("GroupName");
            String originalgroupName = ((HiddenField)FindControl("OriginalGroupName")).Value;

            if (String.IsNullOrEmpty(groupName))
            {
                ErrorMessage = ValidationErrors.UserGroupCannotBeEmpty;
                return(false);
            }

            var controller = new UserManagementController();

            if (controller.ExistsUsergroup(groupName) && !groupName.Equals(originalgroupName))
            {
                ErrorMessage = string.Format(ValidationErrors.UserGroupAlreadyExists, groupName);
                return(false);
            }

            return(true);
        }