// CREATE CONTAINERS private void CreateContainers() { // CREATE OVERVIEW PANEL OverviewContainer = new OverviewContainer(); Controls.Add(OverviewContainer); // CREATE SCRIPT PANEL ScriptContainer = new ScriptContainer { Visible = false }; Controls.Add(ScriptContainer); // CREATE SETTINGS PANEL SettingsContainer = new SettingsContainer { Visible = false }; Controls.Add(SettingsContainer); // CREATE ACTIONS PANEL ActionsContainer = new ActionsContainer { Visible = false }; Controls.Add(ActionsContainer); // CREATE EFFICIENCY PANEL EfficiencyContainer = new EfficiencyContainer { Visible = false }; Controls.Add(EfficiencyContainer); }
public List <CommentOrPost> GetCommentsAndPosts(OverviewContainer overviewContainer, Dispatch dispatch) { if (overviewContainer == null || overviewContainer.Data == null) { return(null); } return(overviewContainer.Data.Children); }
public OverviewContainer Validate(OverviewContainer overviewContainer, int minResults = 1) { Assert.IsNotNull(overviewContainer); Assert.IsNotNull(overviewContainer.Data); Assert.IsNotNull(overviewContainer.Data.Children); Assert.IsTrue(overviewContainer.Data.Children.Count >= minResults); // Each CommentOrPost entry should have exactly one comment or one post-- not neither and not both. --Kris foreach (CommentOrPost commentOrPost in overviewContainer.Data.Children) { Assert.IsTrue(commentOrPost.Comment != null || commentOrPost.Post != null); Assert.IsTrue(commentOrPost.Comment == null || commentOrPost.Post == null); } return(overviewContainer); }
public async Task <IndexViewModel> Calculate(Client client, Db db) { var overviewCalculator = new OverviewCalculator(db, client, new SumCalculator(db, client)); var allCategories = (await overviewCalculator.GetCategories()).ToList(); Overview = new OverviewContainer { CategoryHeaders = allCategories }; var overview = await overviewCalculator.Calculate(); foreach (var monthPair in overview) { var monthContainer = new MonthContainer { Year = monthPair.Key.Date.Year, Month = monthPair.Key.Date.Month, Name = monthPair.Key.ToString(), Income = monthPair.Value.Where(x => x.Key == Constants.IncomeCategory).Sum(x => x.Value), Spent = monthPair.Value.Where(x => x.Key != Constants.IncomeCategory).Sum(x => x.Value) }; foreach (var category in allCategories) { monthContainer[category] = monthPair.Value.ContainsKey(category) ? monthPair.Value[category] : 0; } if (monthContainer.Income > 0 || monthContainer.Spent < 0) { Overview.Months.Insert(0, monthContainer); } } return(this); }