Ejemplo n.º 1
0
        protected BankAccountType GetAccountType(IDemoDbUnitOfWork unitOfWork, AccountType bankAccountType)
        {
            var name = bankAccountType.ToStringValue();

            // In this case I am going to assume all accounts are properly mapped -> First()
            return(unitOfWork.BankAccountTypes.GetAll().Where(a => a.BankAccountTypeName == name).First());
        }
Ejemplo n.º 2
0
        protected BankAccount CreateNew(IDemoDbUnitOfWork unitOfWork, AccountType bankAccountType, string ownerFullName, decimal startingBalance, decimal annualPercentageRate)
        {
            var entity = new BankAccount();

            entity.AnnualPercentageRate = annualPercentageRate;
            entity.Balance           = startingBalance;
            entity.BankAccountTypeId = GetAccountType(unitOfWork, bankAccountType).BankAccountTypeId;
            entity.OwnerFullName     = ownerFullName;

            return(entity);
        }
    public T CreateInstance <T>(IDemoDbUnitOfWork unitOfWork, bool byFullName = false)
    {
        if (unitOfWork == null)
        {
            throw new ArgumentNullException("UnitOfWork");
        }

        var container = IoC.Initialize();

        container.Inject(typeof(IDemoDbUnitOfWork), unitOfWork);

        return(container.GetInstance <T>());
    }
Ejemplo n.º 4
0
    public T CreateInstance <T>(IDemoDbUnitOfWork unitOfWork, bool byFullName = false)
    {
        if (unitOfWork == null)
        {
            throw new ArgumentNullException("UnitOfWork");
        }

        // Here, I am passing-in a MOCK of the UnitOfWork & "shimming" it into "T" via IoC
        var container = IoC.Initialize();

        container.Inject(typeof(IDemoDbUnitOfWork), unitOfWork);

        return(container.GetInstance <T>());
    }
Ejemplo n.º 5
0
        public T CreateInstance <T>(IDemoDbUnitOfWork unitOfWork, bool byFullName = false)
        {
            if (unitOfWork == null)
            {
                throw new ArgumentNullException("UnitOfWork");
            }

            // FORCE: Same instance to be shared across all classes
            DependencyInjectionSingletonFactory.Instance.DependencyInjector.RegisterInstance(unitOfWork);

            var genericType = typeof(T);
            var name        = (!byFullName) ? genericType.Name : genericType.FullName;

            return(DependencyInjectionSingletonFactory.Instance.DependencyInjector.Resolve <T>(name));
        }
Ejemplo n.º 6
0
        public void LoadDataScenario(IDemoDbUnitOfWork unitOfWork, DataScenarios dataScenario)
        {
            if (unitOfWork == null)
            {
                throw new ArgumentNullException("UnitOfWork");
            }

            if (dataScenario == DataScenarios.Default)
            {
                DefaultDataScenario.Load(unitOfWork);
            }

            if (dataScenario == DataScenarios.Overdrafts)
            {
                OverdraftsDataScenario.Load(unitOfWork);
            }
        }
Ejemplo n.º 7
0
        public void Load(IDemoDbUnitOfWork unitOfWork)
        {
            BankAccount record = CreateNew(unitOfWork, AccountType.Checking, "Stacie M Mahon", -150.00M, 1.6M);

            unitOfWork.BankAccounts.Add(record);
        }
Ejemplo n.º 8
0
        public void Load(IDemoDbUnitOfWork unitOfWork)
        {
            BankAccount record = CreateNew(unitOfWork, AccountType.Checking, "Robert M. Jordan", 50.00M, 2.6M);

            unitOfWork.BankAccounts.Add(record);
        }