コード例 #1
0
        public static SpecificationResult IsSatisfiedBy(StudentListModel studentAddUpdateModel, Expression <Func <StudentBl, bool> > predicate)
        {
            var spec = Specification.NotNull <Expression <Func <StudentBl, bool> > >();

            var specificationResult = new SpecificationResult();

            spec.IsSatisfiedBy(predicate, out specificationResult);

            return(specificationResult);
        }
コード例 #2
0
        public static SpecificationResult IsSatisfiedBy(StudentAddUpdateModel studentAddUpdateModel, int minAge, DateTime today)
        {
            var dt = new DateTime(today.Year - minAge, today.Month, today.Day);

            var spec = Specification.NotNull <StudentAddUpdateModel>()
                       .And().NotEmpty(t => t.Student.FirstName)
                       .And().NotEmpty(t => t.Student.LastName)
                       .And().True(t => t.Student.Age > minAge)
                       .And().True(t => t.Student.BirthDate.AddYears(minAge).Date >= today.Date);


            var specificationResult = new SpecificationResult();

            spec.IsSatisfiedBy(studentAddUpdateModel, out specificationResult);

            return(specificationResult);
        }