public async Task AddAsync_NonExistingGuid_AddsToRepo() { var nonExistingGuid = Guid.NewGuid(); _walletRepositoryMock.Setup(r => r.GetByGuidAsync(nonExistingGuid)).Returns(Task.FromResult <Wallet>(null)); await walletService.AddAsync(nonExistingGuid); _walletRepositoryMock.Verify(r => r.AddAsync(nonExistingGuid), Times.Once); }
public async Task <IActionResult> PostAsync(Guid guid) { try { await _walletService.AddAsync(guid); } catch (ArgumentException) { return(BadRequest("Wallet already exists.")); } return(Ok()); }
public async Task RegisterAsync(string email, string username, string password, string confirmPassword) { var user = await _userRepository.FindAsync(email); var userUsername = await _userRepository.FindByUsernameAsync(username); if (user != null) { throw new Exception("User is exists"); } if (userUsername != null && userUsername.Username == username) { throw new Exception("User is exists"); } if (password != confirmPassword) { throw new Exception("Password are not equal"); } // throw new Exception(password + " " + confirmPassword); var salt = _encrypter.GetSalt(password); var hash = _encrypter.GetHash(password, salt); user = new User(email, username, hash, salt, "user"); await _userRepository.AddAsync(user); var coin = new List <string>(); coin.Add("BTC"); coin.Add("USD"); coin.Add("LTC"); coin.Add("ETH"); await _walletService.AddAsync(coin, user.Id); }
public async Task HandlerAsync(AddWallet command) { await _walletService.AddAsync(command.Currencies, command.UserId); }
public async Task <IActionResult> Post(SimulateGoalVM simulateGoalVM) { var result = await _walletService.AddAsync(simulateGoalVM); return(Ok(result)); }