Ejemplo n.º 1
0
            public async Task Handle(V1.AccountClosed @event, CancellationToken cancellationToken)
            {
                var accountDto = await accountDtoRepository.GetAccountByAccountId(@event.AccountId);

                if (accountDto == null)
                {
                    throw new NullReferenceException("No accountDto has been found");
                }

                accountDto.MonthIsClosed = true;

                await accountDtoRepository.Update(accountDto);
            }
Ejemplo n.º 2
0
            public async Task Handle(V1.BookingAddedToAccount @event, CancellationToken cancellationToken)
            {
                var accountDto = await accountDtoRepository.GetAccountByAccountId(@event.AccountId);

                if (accountDto == null)
                {
                    throw new NullReferenceException("No accountDto has been found");
                }

                if (accountDto.Items == null)
                {
                    accountDto.Items = new List <AccountItemDto>();
                }

                accountDto.Items.Add(new AccountItemDto(@event.BookingId, @event.Date, @event.Amount, @event.Description));

                accountDto.TotalSpent = accountDto.Items.Sum(x => x.Amount);

                await accountDtoRepository.Update(accountDto);
            }
Ejemplo n.º 3
0
            public async Task Handle(V1.BookingRemovedFromAccount @event, CancellationToken cancellationToken)
            {
                var accountDto = await accountDtoRepository.GetAccountByAccountId(@event.AccountId);

                if (accountDto == null)
                {
                    throw new NullReferenceException("No accountDto has been found");
                }

                if (accountDto.Items == null)
                {
                    accountDto.Items = new List <AccountItemDto>();
                }

                var bookingItem = accountDto.Items.Single(x => x.BookingId == @event.BookingId);

                accountDto.Items.Remove(bookingItem);

                accountDto.TotalSpent = accountDto.Items.Sum(x => x.Amount);

                await accountDtoRepository.Update(accountDto);
            }
Ejemplo n.º 4
0
        public async Task <AccountDto> Handle(GetAccountDtoByAccountIdQuery request, CancellationToken cancellationToken)
        {
            var accountDtos = await accountDtoRepository.GetAccountByAccountId(request.AccountId);

            return(accountDtos);
        }