public IBankAPI DeterminateBankAPI(SupportedBank supportedBank) { if (supportedBank.Name.Equals("Banca Intesa")) { return(BancaIntesaAPIMockFactory.Create()); } throw new NotFoundBankAPIException("We don't have api from this bank"); }
public async Task <SupportedBankDTO> CreateSupportedBankAsync(string supportedBankName) { var supportedBank = new SupportedBank(supportedBankName); await _unitOfWork.SupportedBankRepository.Insert(supportedBank); await _unitOfWork.SaveChangesAsync(); return(new SupportedBankDTO(supportedBank)); }
public async Task <SupportedBankDTO> GetSupportedBankByIdAsync(int supportedBankId) { SupportedBank supportedBank = await _unitOfWork.SupportedBankRepository.GetById(supportedBankId); if (supportedBank == null) { throw new ArgumentException($"Supported bank with id {supportedBankId} does not exist"); } return(new SupportedBankDTO(supportedBank)); }
public async Task <WalletDTO> ArrangeWalletOnSpecificDateWithAmount(DateTime date, decimal amount) { SupportedBank bank = await _unitOfWork.SupportedBankRepository.GetById(1); Wallet wallet = new Wallet("2108996781057", bank, "Stefan", "Burgic", "061213", "0612"); wallet.ChangeCreatedAtDate(date); wallet.AddAmount(amount); await _unitOfWork.WalletRepository.Insert(wallet); await _unitOfWork.SaveChangesAsync(); return(new WalletDTO(wallet)); }
public async Task <SupportedBankDTO> DeleteSupportedBankAsync(int supportedBankId) { SupportedBank supportedBank = await _unitOfWork.SupportedBankRepository.GetById(supportedBankId); if (supportedBank == null) { throw new ArgumentException($"Supported bank with id {supportedBankId} does not exist"); } await _unitOfWork.SupportedBankRepository.Delete(supportedBank); await _unitOfWork.SaveChangesAsync(); return(new SupportedBankDTO(supportedBank)); }
public static async Task AssemblyInit(TestContext context) { var dbContextFactory = new SampleDbContextFactory(); using (var dbContext = dbContextFactory.CreateDbContext(new string[] { })) { await dbContext.Database.EnsureCreatedAsync(); dbContext.Database.BeginTransaction(); dbContext.SaveChanges(); SupportedBank supportedBankAPI = new SupportedBank("Banca Intesa"); dbContext.SupportedBanks.Add(supportedBankAPI); SupportedBank bankWithNoAPI = new SupportedBank("Random"); dbContext.SupportedBanks.Add(bankWithNoAPI); dbContext.SaveChanges(); dbContext.Database.CommitTransaction(); } }
public async Task <WalletDTO> CreateNewWallet(string uniqueMasterCitizenNumberValue, string postalIndexNumber, int supportedBankId, string firstName, string lastName) { SupportedBank supportedBank = await _unitOfWork.SupportedBankRepository.GetById(supportedBankId); if (supportedBank == null) { throw new ArgumentException($"Supported bank with id {supportedBankId} does not exist"); } IBankAPI bankAPI = _bankAPIDeterminator.DeterminateBankAPI(supportedBank); bool validStatus = await bankAPI.CheckStatus(uniqueMasterCitizenNumberValue, postalIndexNumber); if (!validStatus) { throw new BankAPIException("Bank api - invalid status"); } Wallet existingWallet = await _unitOfWork.WalletRepository.GetFirstOrDefault(Wallet => Wallet.UniqueMasterCitizenNumber.Value == uniqueMasterCitizenNumberValue ); if (existingWallet != null) { throw new ExistingWalletException("Wallet already exist with same UMCN"); } UniqueMasterCitizenNumber uniqueMasterCitizenNumber = new UniqueMasterCitizenNumber(uniqueMasterCitizenNumberValue); if (!uniqueMasterCitizenNumber.ValidForPlatform()) { throw new NotValidUniqueMasterCitizenNumberException("Unique master citizen number not valid for platform"); } string walletPassword = PasswordGenerator.WalletPassword(); Wallet wallet = new Wallet(uniqueMasterCitizenNumberValue, supportedBank, firstName, lastName, walletPassword, postalIndexNumber); await _unitOfWork.WalletRepository.Insert(wallet); await _unitOfWork.SaveChangesAsync(); return(new WalletDTO(wallet)); }
public SupportedBankDTO(SupportedBank supportedBank) { Id = supportedBank.Id; Name = supportedBank.Name; }