private static ReportTotalForView GetView(this ReportTotalForView reportTotalForView, List <TimeEntry> groupedTimeEntries) { var groupByTypeId = reportTotalForView.GroupByTypeId; var showColumnIds = reportTotalForView.ShowColumnIds; reportTotalForView.Items = groupedTimeEntries.Select(x => MapTimeEntryToReportGridItemsView(x, new ReportItemsView(groupByTypeId, showColumnIds))).ToList(); foreach (var groupingTimeEntries in reportTotalForView.Items) { reportTotalForView.TimeTotalFor.TimeActualTotalFor += groupingTimeEntries.TimeValues.TimeActual; reportTotalForView.TimeTotalFor.TimeEstimatedTotalFor += groupingTimeEntries.TimeValues.TimeEstimated; } reportTotalForView.TimeTotalFor.TimeEstimatedTotalFor = reportTotalForView.ShowColumnIds.Contains((int)ShowColumnModelIds.ShowEstimatedTime) ? reportTotalForView.TimeTotalFor.TimeEstimatedTotalFor : null; return(reportTotalForView); }
private static ReportTotalForGroupTypeView GetView <TGroupBy>(this ReportTotalForGroupTypeView reportTotalForGroupTypeView, KeyValuePair <TGroupBy, List <TimeEntry> > dictionaryOfGroupTimeEntries) { var groupByTypeId = reportTotalForGroupTypeView.GroupByTypeId; var showColumnIds = reportTotalForGroupTypeView.ShowColumnIds; var reportTimeTotalForItemsView = new ReportTotalForView(groupByTypeId, showColumnIds).GetView(dictionaryOfGroupTimeEntries.Value); switch (dictionaryOfGroupTimeEntries.Key) { case Project project: { reportTotalForGroupTypeView.GroupByType.ProjectId = project.Id; reportTotalForGroupTypeView.GroupByType.ProjectName = project.Name; reportTotalForGroupTypeView.GroupByType.GroupByTypeDisplayName = reportTotalForGroupTypeView.DisplayNames.DisplayNameProject + ": "; reportTotalForGroupTypeView.GroupByType.GroupByTypeDisplayNameValue = project.Name; //reportTimeTotalForItemsView.DisplayNames.DisplayNameProject = reportTimeTotalForItemsView.GroupByTypeId == (int)ReportsGroupBy.Project ? null : reportTimeTotalForItemsView.DisplayNames.DisplayNameProject; break; } case Member member: { reportTotalForGroupTypeView.GroupByType.MemberId = member.Id; reportTotalForGroupTypeView.GroupByType.MemberName = member.FullName; reportTotalForGroupTypeView.GroupByType.GroupByTypeDisplayName = reportTotalForGroupTypeView.DisplayNames.DisplayNameMember + ": "; reportTotalForGroupTypeView.GroupByType.GroupByTypeDisplayNameValue = member.FullName; //reportTimeTotalForItemsView.DisplayNames.DisplayNameMember = reportTimeTotalForItemsView.GroupByTypeId == (int)ReportsGroupBy.Member ? null : reportTimeTotalForItemsView.DisplayNames.DisplayNameMember; break; } case DateTime dateTime: { reportTotalForGroupTypeView.GroupByType.Date = dateTime; reportTotalForGroupTypeView.GroupByType.GroupByTypeDisplayName = reportTotalForGroupTypeView.DisplayNames.DisplayNameDate + ": "; reportTotalForGroupTypeView.GroupByType.GroupByTypeDisplayNameValue = UpdateDateFormat(dateTime, reportTotalForGroupTypeView.DateFormatId); //reportTimeTotalForItemsView.DisplayNames.DisplayNameDate = reportTimeTotalForItemsView.GroupByTypeId == (int)ReportsGroupBy.Date ? null : reportTimeTotalForItemsView.DisplayNames.DisplayNameDate; break; } case Client client: { reportTotalForGroupTypeView.GroupByType.ClientId = client.Id; reportTotalForGroupTypeView.GroupByType.ClientName = client.Name; reportTotalForGroupTypeView.GroupByType.GroupByTypeDisplayName = client.Id == WithoutClient.Id ? null : reportTotalForGroupTypeView.DisplayNames.DisplayNameClient + ": "; reportTotalForGroupTypeView.GroupByType.GroupByTypeDisplayNameValue = client.Name; //reportTimeTotalForItemsView.DisplayNames.DisplayNameClient = reportTimeTotalForItemsView.GroupByTypeId == (int)ReportsGroupBy.Client ? null : reportTimeTotalForItemsView.DisplayNames.DisplayNameClient; break; } } //reportTotalForGroupTypeView.DisplayNames = reportTimeTotalForItemsView.DisplayNames; reportTotalForGroupTypeView.TimeTotalFor = reportTimeTotalForItemsView.TimeTotalFor; reportTotalForGroupTypeView.Items = reportTimeTotalForItemsView.Items; return(reportTotalForGroupTypeView); }