Ejemplo n.º 1
0
        public DistributionModelTests()
        {
            DebitCardAccount = new AccountModel
            {
                Id           = 1,
                AccountType  = AccountType.DebitCard,
                AvailBalance = 15000
            };
            CashAccount = new AccountModel
            {
                Id           = 2,
                AccountType  = AccountType.Cash,
                AvailBalance = 1200
            };
            FoodFlow = new ExpenseFlowModel
            {
                Id      = 1,
                Balance = 100,
            };
            TechFlow = new ExpenseFlowModel
            {
                Id      = 2,
                Balance = 0
            };

            Debit = new DistributionAccount
            {
                Account           = DebitCardAccount,
                UseInDistribution = true
            };
            Cash = new DistributionAccount
            {
                Account           = CashAccount,
                UseInDistribution = true
            };

            Food = new DistributionItem
            {
                Flow   = FoodFlow,
                Mode   = DistributionMode.RegularExpenses,
                Amount = 10000
            };
            Tech = new DistributionItem
            {
                Flow   = TechFlow,
                Mode   = DistributionMode.Accumulation,
                Amount = 1000
            };

            Model = new DistributionModel
            {
                Accounts = new List <DistributionAccount> {
                    Debit, Cash
                },
                Items = new List <DistributionItem> {
                    Food, Tech
                }
            };
        }
Ejemplo n.º 2
0
        private async Task CreateOrUpdateAcccountSettings(DistributionAccount distributionAccount)
        {
            var settings = await _repository.GetQuery <AccountFlowSettings>()
                           .Where(x => x.AccountId == distributionAccount.Account.Id)
                           .SingleOrDefaultAsync();

            if (settings == null)
            {
                settings = new AccountFlowSettings
                {
                    AccountId = distributionAccount.Account.Id,
                    CanFlow   = distributionAccount.UseInDistribution
                };
                _repository.Create(settings);
            }
            else
            {
                settings.CanFlow = distributionAccount.UseInDistribution;
                _repository.Update(settings);
            }
        }