예제 #1
0
        private void Initialize(BookAddPagesInputDto book, EntityDependency[] dependencies)
        {
            RegisterCommandRepositoryFactory <Book>(() => new BookCommandRepository());

            RootEntity = new Book
            {
                Id = book.BookId
            };

            if (book.Pages?.Any() == true)
            {
                foreach (var dto in book.Pages)
                {
                    ILinkedAggregateCommandOperation operation;

                    if (dto is SavePageInputDto)
                    {
                        operation = new AddLinkedAggregateCommandOperation <Book, CreatePageCommandAggregate, SavePageInputDto>(
                            RootEntity,
                            (SavePageInputDto)dto,
                            new EntityDependency[]
                        {
                            new EntityDependency
                            {
                                Entity   = RootEntity,
                                Selector = "Pages"
                            }
                        }
                            );

                        Enqueue(operation);
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
            }
        }
예제 #2
0
 public AddBookPagesCommandAggregate(BookAddPagesInputDto book, EntityDependency[] dependencies = null) : base(new DomainFramework.DataAccess.RepositoryContext(BookWithPagesConnectionClass.GetConnectionName()))
 {
     Initialize(book, dependencies);
 }