コード例 #1
0
        public async Task AddAccountAsync(AddAccountRequest request)
        {
            var users = await userDbHandler.GetUsersAsync();

            var user = users.FirstOrDefault(u => u.Id == request.UserId);

            if (user == null)
            {
                throw new UserNotFountException(request.UserId);
            }

            if (user.Salary - user.Expenses < 1000)
            {
                throw new UserIsNotEligibleToCreateAccountException();
            }

            var account = new Account()
            {
                UserId = request.UserId, CreationDate = DateTime.UtcNow, IsActive = true
            };
            await accountDbHandler.AddAccountAsync(account);
        }
コード例 #2
0
        public async Task <IEnumerable <UserDto> > GetAllUsersAsync()
        {
            var users = await userDbHandler.GetUsersAsync();

            return(users.ToUserDto());
        }