/// <summary> /// Metoda koja pravi wallet /// </summary> /// <param name="walletDTO"></param> /// <returns>Id</returns> public async Task <WalletDTO> CreateWallet(WalletDTO walletDTO) { var result = await UnitOfWork.WalletRepository.GetFirstOrDefaultWithIncludes(m => m.JMBG == walletDTO.JMBG); if (result != null) { throw new WalletServiceException("Novcanik sa ovim JMBG-om vec postoji!", "CreateWallet: Duplicate JMBG"); } bool isValid = await BankService.CheckStatus(walletDTO.JMBG, walletDTO.PIN); if (!isValid) { new WalletServiceException("PIN nije validan!", "CreateWallet: Invalid PIN"); } string pass = PassService.GeneratePASS(); Wallet newWallet = new Wallet(walletDTO.FirstName, walletDTO.LastName, walletDTO.JMBG, walletDTO.Bank, walletDTO.PIN, walletDTO.BankAccount, pass); await UnitOfWork.WalletRepository.Insert(newWallet); await UnitOfWork.SaveChangesAsync(); return(new WalletDTO(newWallet)); }