예제 #1
0
        public async Task Handle(UserTransactionEvent @event)
        {
            _logger.LogInformation("Received {Event} event at {AppName}", @event.GetType().Name, Program.AppName);

            var user = await _repository.GetEntityByID(@event.UserId);

            if (user == null)
            {
                return;
            }

            user.Balance -= @event.Amount;
            await _repository.UpdateEntity(user);
        }
예제 #2
0
        public async Task Handle(UserNameUpdatedEvent @event)
        {
            _logger.LogInformation("Received {Event} event at {AppName}", @event.GetType().Name, Program.AppName);

            var existingJobs = _repository.GetQueryableEntities().Where(j => j.CreatedByUserId == @event.UserId);

            if (!existingJobs.Any())
            {
                return;
            }

            foreach (var job in existingJobs.ToList())
            {
                job.CreatedByUserName = @event.NewName;
                await _repository.UpdateEntity(job, autoSave : false);
            }
            await _repository.Save();
        }