Beispiel #1
0
        public InsertCountryWithCapitalCityCommandAggregate(CountryWithCapitalCityDto countryWithCapitalCity)
            : base(new DataAccess.RepositoryContext("SqlServerTest.DomainFrameworkOneToOneTest.ConnectionString"))
        {
            RegisterCommandRepositoryFactory <CountryEntity>(() => new CountryCommandRepository());

            RegisterCommandRepositoryFactory <CapitalCityEntity>(() => new CapitalCityCommandRepository());

            RootEntity = new CountryEntity
            {
                Id   = countryWithCapitalCity.CountryCode,
                Name = countryWithCapitalCity.Name
            };

            Enqueue(
                new InsertEntityCommandOperation <CountryEntity>(RootEntity)
                );

            if (countryWithCapitalCity.CapitalCity != null)
            {
                CapitalCity = new CapitalCityEntity
                {
                    Name = countryWithCapitalCity.CapitalCity.Name
                };

                Enqueue(
                    new AddLinkedEntityCommandOperation <CountryEntity, CapitalCityEntity>(
                        RootEntity,
                        getLinkedEntity: () => CapitalCity
                        )
                    );
            }
        }
        public UpdateCountryCommandAggregate(CountryWithCapitalCityDto countryWithCapitalCity)
            : base(new DataAccess.RepositoryContext("SqlServerTest.DomainFrameworkOneToOneTest.ConnectionString"))
        {
            RegisterCommandRepositoryFactory <CountryEntity>(() => new CountryCommandRepository());

            RegisterCommandRepositoryFactory <CapitalCityEntity>(() => new CapitalCityCommandRepository());

            RootEntity = new CountryEntity
            {
                Id   = countryWithCapitalCity.CountryCode,
                Name = countryWithCapitalCity.Name
            };

            Enqueue(
                new UpdateEntityCommandOperation <CountryEntity>(RootEntity)
                );
        }