//validation
        protected bool ValidateCourse(Course courseToValidate)
        {
            if (String.IsNullOrWhiteSpace(courseToValidate.Title))//general requirements not null
            {
                Validator.AddError("Creating.Title", "Title is required");
            }
            if (String.IsNullOrWhiteSpace(courseToValidate.courseCode))
            {
                Validator.AddError("Creating.CourseCode", "Course code is required");
            }

            if (courseToValidate.DayOfWeek < 0 || courseToValidate.DayOfWeek > 7)//bounds validation for day of week and time
            {
                Validator.AddError("DayOfWeek", "Day of week is out of range");
            }
            if (courseToValidate.TimeOfDay < 0 || courseToValidate.TimeOfDay > 23)//time
            {
                Validator.AddError("TimeOfDay", "Time of day is out of range");
            }
            if (courseToValidate.Term == null)
            {
                Validator.AddError("Term", "Please specify a term");
            }

            return(Validator.IsValid);
        }
Example #2
0
        /*
         * public bool CreateComment(Comment creating)
         * {
         *  if (ValidateComment(creating))
         *      return Repository.CreateComment(creating);
         *
         *  return false;
         * }
         */
        //validation
        protected bool ValidateComment(Comment validating)
        {
            if (String.IsNullOrWhiteSpace(validating.Title))
            {
                Validator.AddError("Creating.Title", "You must have a title");
            }
            if (String.IsNullOrWhiteSpace(validating.Text))
            {
                Validator.AddError("Creating.Text", "You must have a body");
            }
            if (validating.Staff == -1)//no staff selected
            {
                Validator.AddError("Creating.Staff", "You must select staff to certify");
            }

            return(Validator.IsValid);
        }
Example #3
0
        //validation
        protected bool ValidateUser(CreateEditUserViewModel validate)
        {
            if (String.IsNullOrWhiteSpace(validate.Editing.FirstName))
            {
                Validator.AddError("Editing.FirstName", "First name is required");
            }
            if (String.IsNullOrWhiteSpace(validate.Editing.LastName))
            {
                Validator.AddError("Editing.LastName", "Last name is required");
            }
            if (String.IsNullOrWhiteSpace(validate.Editing.UserType))
            {
                Validator.AddError("Editing.UserType", "User type is required");
            }
            if (validate.Editing.UserType != null && validate.Editing.UserType.ToLower().Equals("student") && String.IsNullOrWhiteSpace(validate.Editing.ClassInSchool))
            {
                Validator.AddError("Editing.ClassInSchool", "You must select a class in school for students");
            }
            if (validate.StaffID == 0)
            {
                Validator.AddError("Editing.StaffID", "Staff Creator is required");
            }

            return(Validator.IsValid);
        }
Example #4
0
        private bool ValidateVisitType(VisitType validating)
        {
            if (String.IsNullOrWhiteSpace(validating.Title))
            {
                Validator.AddError("Title", "You must enter a title");
            }


            return(Validator.IsValid);
        }
Example #5
0
        protected bool ValidateIndividualReport(Report input)
        {
            if (input.Start.Year == 0001)
            {
                Validator.AddError("Start", "Start date is required");
            }
            if (input.Finish.Year == 0001)
            {
                Validator.AddError("Finish", "End date is required");
            }
            if (input.Start > input.Finish)
            {
                Validator.AddError("Finish", "Finish date must be after Start date");
            }
            if (String.IsNullOrEmpty(input.First))
            {
                Validator.AddError("First", "First Name is required");
            }
            if (String.IsNullOrEmpty(input.Last))
            {
                Validator.AddError("Last", "Last Name is required");
            }
            if (String.IsNullOrEmpty(input.FileName))
            {
                Validator.AddError("FileName", "File Name is required");
            }

            return(Validator.IsValid);
        }