Example #1
0
        public void Print(ITextOutput output, TableFormatter tableFormatter)
        {
            var table = CreateTable();

            foreach (var issueView in Issues)
            {
                object[] currentRow = table.AddRow(issueView.Name);
                for (int i = 1; i < table.Columns.Count; i++)
                {
                    var    currentWorkDay     = WorkingDays.SingleOrDefault(x => x.Date.Equals(table.Columns[i].Value));
                    double?totalHoursPerIssue = currentWorkDay?.GetTotalHoursByIssue(issueView);
                    // TODO: move tostring into formatter it doesn't belongs here
                    currentRow[i] = totalHoursPerIssue > 0 ? totalHoursPerIssue.Value.ToString("0.##") : null;
                }
            }

            var currentFooterRow = table.AddFooterRow("Total hours:");

            for (int i = 1; i < table.Columns.Count; i++)
            {
                var day = WorkingDays.SingleOrDefault(x => x.Date.Equals(table.Columns[i].Value));
                //TODO: move tostring into formatter it doesn't belongs here
                currentFooterRow[i] = day?.TotalHours.ToString("0.##");
            }

            //TODO: move tostring into formatter it doesn't belongs here
            table.AddFooterRow($"Total hours for period logged/expected: {TotalHoursInPeriod.ToString("0.##")}" +
                               $"/{ExpectedTotalHoursInPeriod.ToString("0.##")}");

            tableFormatter.Write(table, output);
        }