コード例 #1
0
        public async Task Initialize(InitializeBookStoreCommand cmd)
        {
            var @event = new BookStoreInitializedEvent(
                cmd.Id,
                cmd.Name,
                new AddressEventData(cmd.Address.Country, cmd.Address.City, cmd.Address.Street, cmd.Address.Building));

            RaiseEvent(@event);
            await ConfirmEvents();
        }
コード例 #2
0
        private async Task Apply(BookStoreInitializedEvent @event, long version)
        {
            using (var db = new ApplicationDbContext(Configuration.ConnectionString))
            {
                await UpdateStreamVersion(db, version);

                CreateBookStore(db, @event);

                await db.SaveChangesAsync();
            }
        }
コード例 #3
0
 public void Apply(BookStoreInitializedEvent @event)
 {
     Id      = @event.Id;
     Name    = @event.Name;
     Address = new AddressData
     {
         Country  = @event.Address.Country,
         City     = @event.Address.City,
         Street   = @event.Address.Street,
         Building = @event.Address.Building
     };
 }
コード例 #4
0
        private void CreateBookStore(ApplicationDbContext db, BookStoreInitializedEvent @event)
        {
            _log.Debug($"Creating book store entity {@event.Id}");

            var bookStore = new Database.Entities.BookStore
            {
                Id      = @event.Id,
                Name    = @event.Name,
                Address = JsonConvert.SerializeObject(@event.Address)
            };

            db.BookStores.Add(bookStore);
        }