예제 #1
0
파일: AccountDb.cs 프로젝트: RayTale/Vertex
        public Task EventHandle(TopupEvent evt, EventMeta eventBase)
        {
            Interlocked.Increment(ref this.executedTimes);

            // Update database here
            return(Task.CompletedTask);
        }
예제 #2
0
        public async Task TopUp(decimal amount, string flowId)
        {
            var evt = new TopupEvent
            {
                Amount  = amount,
                Balance = this.Snapshot.Data.Balance + amount
            };

            await this.RaiseEvent(evt, flowId);
        }
예제 #3
0
        public Task <bool> TopUp(decimal amount)
        {
            var evt = new TopupEvent
            {
                Amount  = amount,
                Balance = Snapshot.State.Balance + amount
            };

            return(RaiseEvent(evt));
        }
예제 #4
0
        public Task <bool> TopUp(decimal amount, string topupId)
        {
            var evt = new TopupEvent
            {
                Amount  = amount,
                Balance = this.Snapshot.Data.Balance + amount
            };

            return(this.RaiseEvent(evt, topupId));
        }
예제 #5
0
        public async Task EventHandle(TopupEvent evt, EventMeta eventBase)
        {
            using (var db = this.ServiceProvider.GetService <TransferDbContext>())
            {
                var entity = await db.Accounts.FirstOrDefaultAsync(x => x.Id == this.ActorId);

                this.accountSnapshotHandler.EntityHandle(entity, evt);
                await db.SaveChangesAsync();
            }
        }
예제 #6
0
 public Task <bool> TopUp(decimal amount)
 {
     return(ConcurrentRaiseEvent(async(snapshot, func) =>
     {
         var evt = new TopupEvent
         {
             Amount = amount,
             Balance = Snapshot.State.Balance + amount
         };
         await func(evt, null);
     }));
 }
예제 #7
0
 public Task <bool> TopUp(decimal amount, string flowId)
 {
     return(this.ConcurrentRaiseEvent(async(snapshot, func) =>
     {
         var evt = new TopupEvent
         {
             Amount = amount,
             Balance = this.Snapshot.Data.Balance + amount
         };
         await func(evt);
     }, flowId));
 }
예제 #8
0
 public void EventHandle(AccountState state, TopupEvent evt)
 {
     state.Balance = evt.Balance;
 }
예제 #9
0
파일: AccountDb.cs 프로젝트: zhuthree/Ray
 public Task EventHandle(TopupEvent evt, EventBase eventBase)
 {
     //此处更新db
     return(Task.CompletedTask);
 }
예제 #10
0
파일: AccountDb.cs 프로젝트: RayTale/Vertex
 public Task EventHandle(TopupEvent evt, EventMeta eventBase)
 {
     // Update database here
     return(Task.CompletedTask);
 }
예제 #11
0
 public void EntityHandle(Account entity, TopupEvent evt)
 {
     entity.Balance = evt.Balance;
 }
예제 #12
0
 public void EventHandle(AccountSnapshot state, TopupEvent evt)
 {
     EntityHandle(state, evt);
 }