Пример #1
0
        public static ValidatorResult IsValidCourseCustomer(CourseCustomerCastDTO courseCustomerCast)
        {
            ValidatorResult validatorResult = new ValidatorResult(true);

            if (courseCustomerCast == null)
            {
                validatorResult.IsValid           = false;
                validatorResult.ValidationMessage = "The courseCustomerCast is null.";
                return(validatorResult);
            }

            if (courseCustomerCast.CourseId == 0)
            {
                validatorResult.IsValid           = false;
                validatorResult.ValidationMessage = "The courseId is required.";
                return(validatorResult);
            }
            if (courseCustomerCast.CustomerId.Trim().Equals(""))
            {
                validatorResult.IsValid           = false;
                validatorResult.ValidationMessage = "The customerId is required.";
                return(validatorResult);
            }
            return(validatorResult);
        }
        public static ValidatorResult IsValidCourse(CourseDTO course)
        {
            ValidatorResult validatorResult = new ValidatorResult(true);

            if (course == null)
            {
                validatorResult.IsValid           = false;
                validatorResult.ValidationMessage = "The course is null.";
                return(validatorResult);
            }

            if (course.Name.Trim().Equals(""))
            {
                validatorResult.IsValid           = false;
                validatorResult.ValidationMessage = "The course name is required.";
                return(validatorResult);
            }
            if (course.Description.Trim().Equals(""))
            {
                validatorResult.IsValid           = false;
                validatorResult.ValidationMessage = "The course description is required.";
                return(validatorResult);
            }
            if (course.Length == 0)
            {
                validatorResult.IsValid           = false;
                validatorResult.ValidationMessage = "The course length is required.";
                return(validatorResult);
            }
            if (!course.StartDate.HasValue)
            {
                validatorResult.IsValid           = false;
                validatorResult.ValidationMessage = "The user start date is required.";
                return(validatorResult);
            }
            if (!course.EndDate.HasValue)
            {
                validatorResult.IsValid           = false;
                validatorResult.ValidationMessage = "The user end date is required.";
                return(validatorResult);
            }
            return(validatorResult);
        }
Пример #3
0
        public static ValidatorResult IsValidUser(UserRegisterDTO user)
        {
            ValidatorResult validatorResult = new ValidatorResult(true);

            if (user == null)
            {
                validatorResult.IsValid           = false;
                validatorResult.ValidationMessage = "The user is null.";
                return(validatorResult);
            }

            if (user.Username.Trim().Equals(""))
            {
                validatorResult.IsValid           = false;
                validatorResult.ValidationMessage = "The user username is required.";
                return(validatorResult);
            }
            if (user.Password.Trim().Equals(""))
            {
                validatorResult.IsValid           = false;
                validatorResult.ValidationMessage = "The user password is required.";
                return(validatorResult);
            }
            if (user.CustomerId.Trim().Equals(""))
            {
                validatorResult.IsValid           = false;
                validatorResult.ValidationMessage = "The CustomerId is required.";
                return(validatorResult);
            }
            else if (user.Password.Trim().Length < 8)
            {
                validatorResult.IsValid           = false;
                validatorResult.ValidationMessage = "The user password length is short.Password length must be at less 8 characters.";
                return(validatorResult);
            }
            return(validatorResult);
        }