public Task <AsyncTaskResult> HandleAsync(UserGiftAddedEvent evnt)
 {
     return(TryTransactionAsync(async(connection, transaction) =>
     {
         //尽管是更新ExpressAddresssTable但是也要更新聚合跟,因为地址属于聚合跟的状态
         var effectedRows = await connection.UpdateAsync(new
         {
             Version = evnt.Version,
             EventSequence = evnt.Sequence
         }, new
         {
             Id = evnt.AggregateRootId,
             //Version = evnt.Version - 1
         }, ConfigSettings.UserTable, transaction);
         if (effectedRows == 1)
         {
             await connection.InsertAsync(new
             {
                 Id = evnt.UserGiftId,
                 UserId = evnt.AggregateRootId,
                 GiftName = evnt.GiftInfo.Name,
                 GiftSize = evnt.GiftInfo.Size,
                 Name = evnt.ExpressAddressInfo.Name,
                 Region = evnt.ExpressAddressInfo.Region,
                 Address = evnt.ExpressAddressInfo.Address,
                 Zip = evnt.ExpressAddressInfo.Zip,
                 Mobile = evnt.ExpressAddressInfo.Mobile,
                 Remark = evnt.Remark,
                 CreatedOn = evnt.Timestamp
             }, ConfigSettings.UserGiftTable, transaction);
         }
     }));
 }
Пример #2
0
 private void Handle(UserGiftAddedEvent evnt)
 {
 }
Пример #3
0
 private void Handle(UserGiftAddedEvent evnt)
 {
     _userGifts.Add(new UserGift(evnt.UserGiftId, evnt.GiftInfo, evnt.ExpressAddressInfo, evnt.Remark));
 }