示例#1
0
        public AccountDTO getAccountById(int accountId)
        {
            Account account = accountRepository.GetByID(accountId);

            if (account == null)
            {
                throw new InvalidOperationException("No account found with that accountId");
            }
            return(AccountConverter.toDto(account));
        }
示例#2
0
        public AccountDTO updateAccount(int accountId, AccountDTO accountDto)
        {
            Account account = accountRepository.GetByID(accountId);

            if (account == null)
            {
                throw new InvalidOperationException("No account found with that id");
            }

            account.Amount = accountDto.Amount;

            accountRepository.Update(account);
            return(AccountConverter.toDto(account));
        }
示例#3
0
        public AccountDTO createAccount(AccountDTO accountDto)
        {
            if (accountDto.Amount < 0)
            {
                throw new InvalidOperationException("Impossible to have a negative balance");
            }
            Account account = new Account
            {
                Client       = null,
                CreationDate = DateTime.Now,
                Amount       = accountDto.Amount,
                Id           = accountDto.Id,
                Type         = accountDto.Type
            };

            accountRepository.Insert(account);

            return(AccountConverter.toDto(account));
        }