// 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); }
// 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); }
// 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)); }
// 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)); }