コード例 #1
0
        // Create student
        public static StudentCreate.Response Handle(IRepository repository, StudentCreate.Request request)
        {
            var container = new EntityStateWrapperContainer();
            container.AddEntity(StudentFactory.Create(request.CommandModel));
            var validationDetails = repository.Save(container);

            var studentId = default(int?);
            if (!validationDetails.HasValidationIssues)
                studentId = container.FindEntity<Student>().ID;

            return new StudentCreate.Response(validationDetails, studentId);
        }
コード例 #2
0
        // Create course
        public static CourseCreate.Response Handle(IRepository repository, CourseCreate.Request request)
        {
            // Validation now performed in the dispacther decorators (See AutoValidate<T> in the DomainBootstrapper class)

            var container = new EntityStateWrapperContainer();
            container.AddEntity(CourseFactory.Create(request.CommandModel));
            var validationDetails = repository.Save(container);

            var courseId = default(int?);
            if (!validationDetails.HasValidationIssues)
                courseId = container.FindEntity<Course>().CourseID;

            return new CourseCreate.Response(validationDetails, courseId);
        }
コード例 #3
0
        // Create student
        public static StudentCreate.Response Handle(IRepository repository, StudentCreate.Request request)
        {
            var container = new EntityStateWrapperContainer();

            container.AddEntity(StudentFactory.Create(request.CommandModel));
            var validationDetails = repository.Save(container);

            var studentId = default(int?);

            if (!validationDetails.HasValidationIssues)
            {
                studentId = container.FindEntity <Student>().ID;
            }

            return(new StudentCreate.Response(validationDetails, studentId));
        }
コード例 #4
0
        // Create course
        public static CourseCreate.Response Handle(IRepository repository, CourseCreate.Request request)
        {
            // Validation now performed in the dispacther decorators (See AutoValidate<T> in the DomainBootstrapper class)

            var container = new EntityStateWrapperContainer();

            container.AddEntity(CourseFactory.Create(request.CommandModel));
            var validationDetails = repository.Save(container);

            var courseId = default(int?);

            if (!validationDetails.HasValidationIssues)
            {
                courseId = container.FindEntity <Course>().CourseID;
            }

            return(new CourseCreate.Response(validationDetails, courseId));
        }