コード例 #1
0
 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");
 }
コード例 #2
0
        public async Task <SupportedBankDTO> CreateSupportedBankAsync(string supportedBankName)
        {
            var supportedBank = new SupportedBank(supportedBankName);
            await _unitOfWork.SupportedBankRepository.Insert(supportedBank);

            await _unitOfWork.SaveChangesAsync();

            return(new SupportedBankDTO(supportedBank));
        }
コード例 #3
0
        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));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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();
            }
        }
コード例 #7
0
        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));
        }
コード例 #8
0
 public SupportedBankDTO(SupportedBank supportedBank)
 {
     Id   = supportedBank.Id;
     Name = supportedBank.Name;
 }