public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            _conetext = (JobBoardContext)validationContext.GetService(typeof(JobBoardContext));
            //throw new NotImplementedException();

            if (string.IsNullOrEmpty(CompanyName))
            {
                yield return(new ValidationResult("Company Name must required"));
            }

            yield return(ValidationResult.Success);
        }
示例#2
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            _context = (JobBoardContext)validationContext.GetService(typeof(JobBoardContext));

            if (string.IsNullOrEmpty(JobTitle))
            {
                yield return(new ValidationResult("Title must required"));
            }
            if (string.IsNullOrEmpty(Category))
            {
                yield return(new ValidationResult("Please select the category"));
            }
            if (string.IsNullOrEmpty(Jobtype))
            {
                yield return(new ValidationResult("Please select the jobtype"));
            }
            if (string.IsNullOrEmpty(JobDescription))
            {
                yield return(new ValidationResult("Please Add Job Description"));
            }
            if (!string.IsNullOrEmpty(JobPostDate.ToString()))
            {
                if (JobPostDate < DateTime.Now.Date)
                {
                    yield return(new ValidationResult("Job Posting Date must not be in past"));
                }
            }
            else
            {
                yield return(new ValidationResult("Please Select Job Posting Date and Time"));
            }

            if (!string.IsNullOrEmpty(JobExpiryDate.ToString()))
            {
                if (JobExpiryDate < DateTime.Now)
                {
                    yield return(new ValidationResult("Job Expiry Date must be in Future"));
                }
            }
            else
            {
                yield return(new ValidationResult("Please Select Job Expiry Date and Time"));
            }

            yield return(ValidationResult.Success);
        }