protected override void OnRefreshRequest(RefreshEvent refreshEvent) { Diagnostics.Start(); if (refreshEvent.Sender == typeof(ExpensesViewModel).Name) { AllBudgetPlanList.ForEach(x => x.RefreshUI()); } Diagnostics.Stop(); }
private void DetachFromBudgetPlanItems() { Diagnostics.Start(); AllBudgetPlanList.ForEach(x => { x.Values.CollectionChanged -= BudgetPlanListCollectionChanged; }); Diagnostics.Stop(); }
private BudgetPlanItemVM FindBudgetPlanItemVMFor(BudgetPlan budgetPlan) { Diagnostics.Start(); var budgetPlanItem = AllBudgetPlanList .Where(x => x.CashFlow.Id == budgetPlan.CashFlowId && x.Budget.Id == budgetPlan.BudgetId) .First(); Diagnostics.Stop(); return(budgetPlanItem); }
private void AttachToBudgetPlanItems() { Diagnostics.Start(); AllBudgetPlanList.ForEach(x => { x.Values.CollectionChanged += BudgetPlanListCollectionChanged; x.Values.PropertyChanged += (s, e) => { SaveBudgetPlan(s as BudgetPlan); }; }); Diagnostics.Stop(); }
private void LoadBudgetPlanItems() { Diagnostics.Start(); var cashFlows = CachedService.GetAllCashFlows(); var sql = PetaPoco.Sql.Builder .Select("*") .From("BudgetPlan") .InnerJoin("Budget") .On("Budget.Id = BudgetPlan.BudgetId") .InnerJoin("CashFlow") .On("CashFlow.Id = BudgetPlan.CashFlowId") .InnerJoin("CashFlowGroup") .On("CashFlow.CashFlowGroupId = CashFlowGroup.Id") .Where("BudgetPlan.BudgetId = @0", Budget.Id); var budgetPlans = Database.Query <BudgetPlan, Budget, CashFlow, CashFlowGroup>(sql).ToList(); Budget.BudgetPlanItems.Clear(); ((BindableCollectionExt <BudgetPlan>)Budget.BudgetPlanItems).AddRange(budgetPlans); DetachFromBudgetPlanItems(); AllBudgetPlanList.Clear(); foreach (var cashFlow in cashFlows) { var planItems = budgetPlans.Where(x => x.CashFlow.Id == cashFlow.Id).ToList(); AllBudgetPlanList.Add(new BudgetPlanItemVM(Budget, cashFlow, planItems)); } BudgetPlanListGrouped.Clear(); cashFlows.GroupBy(x => x.GroupName).ForEach(cf => { var groupBudgetPlanItems = AllBudgetPlanList.Where(x => x.GroupName == cf.Key).ToList(); var groupedItem = new BudgetPlanGroupItemVM(groupBudgetPlanItems) { GroupName = cf.Key, }; BudgetPlanListGrouped.Add(groupedItem); }); AttachToBudgetPlanItems(); Diagnostics.Stop(); }