public void Update(MoneyAccount t)
 {
     var existing = _currentMoneyAccountState.SingleOrDefault(a => a.Id == t.Id);
     if (existing != null)
     {
         existing.UserId = t.UserId;
         existing.Balance = t.Balance;
     }
 }
Example #2
0
        public string CreateUserMoneyAccount(string userId, decimal initBalance = 100)
        {
            if (_moneyAccountRepo.GetUserMoneyAccount(userId) != null)
            {
                return $"User ID {userId} already exists. Choose another User ID";
            }

            initBalance = initBalance < 0 ? 100 : initBalance;
            var moneyAccount = new MoneyAccount
            {
                UserId = userId,
                Balance = initBalance
            };

            _moneyAccountRepo.Insert(moneyAccount);

            return string.Empty;
        }
 public void Update(MoneyAccount t)
 {
     throw new NotImplementedException();
 }
 public void Insert(MoneyAccount t)
 {
     var random = new Random();
     t.Id = random.Next(1, Int32.MaxValue);
     _currentMoneyAccountState.Add(t);
 }
 public void Insert(MoneyAccount t)
 {
     throw new NotImplementedException();
 }