コード例 #1
0
        /// <summary>
        /// Loads the full tree of funds and budgets
        /// </summary>
        public async Task <Fund> Run()
        {
            Fund root = await this.unitOfWork.GetRepository <Fund>()
                        .GetAll()
                        .Include(f => f.Duration)
                        .SingleAsync(b => b.UserId == this.userId &&
                                     b.ParentFund == null);

            DateTime           currentTime = DateTime.Now;
            IQuerySet <Budget> rootBudgets = this.unitOfWork.GetRepository <Budget>()
                                             .GetAll()
                                             .Include(b => b.BudgetPeriod)
                                             .Where(b => b.FundId == root.Id);
            Budget currentRootBudget = await BudgetPeriodQueryUtils.GetForDate(rootBudgets, DateTime.Now);

            currentRootBudget.Fund = root;
            root.HistoricalBudgets = new List <Budget>()
            {
                currentRootBudget
            };

            root = await this.budgetLoader.LoadFundTree(root, currentRootBudget.BudgetPeriod);

            return(root);
        }
コード例 #2
0
        public async Task <Fund> Run()
        {
            DateTime                   now        = DateTime.Now.Date;
            IRepository <Fund>         fundRepo   = this.unitOfWork.GetRepository <Fund>();
            IRepository <BudgetPeriod> periodRepo = this.unitOfWork.GetRepository <BudgetPeriod>();
            Fund rootFund = await fundRepo.GetAll()
                            .SingleAsync(f => f.UserId == this.userId &&
                                         !f.ParentFundId.HasValue);

            IQuerySet <BudgetPeriod> usersBudgetPeriods = periodRepo.GetAll().Include(p => p.RootBudget)
                                                          .Where(p => p.RootBudget.FundId == rootFund.Id);
            BudgetPeriod currentPeriod = await BudgetPeriodQueryUtils.GetForDate(usersBudgetPeriods, this.date);

            rootFund = await this.budgetLoader.LoadFundTree(rootFund, currentPeriod);

            return(rootFund);
        }