Ejemplo n.º 1
0
 /// <summary>
 /// 处理 添加快递地址
 /// </summary>
 /// <param name="evnt"></param>
 /// <returns></returns>
 public Task <AsyncTaskResult> HandleAsync(ExpressAddressAddedEvent 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.ExpressAddressId,
                 Name = evnt.Info.Name,
                 Region = evnt.Info.Region,
                 Address = evnt.Info.Address,
                 Zip = evnt.Info.Zip,
                 Mobile = evnt.Info.Mobile,
                 UserId = evnt.AggregateRootId,
                 CreatedOn = evnt.Timestamp
             }, ConfigSettings.ExpressAddressTable, transaction);
         }
     }));
 }
Ejemplo n.º 2
0
 private void Handle(ExpressAddressAddedEvent evnt)
 {
     _expressAddresses.Add(new ExpressAddress(evnt.ExpressAddressId, evnt.Info));
 }