/// <summary> /// Handles status counts of personal goals which are aligned to multiple team goals. /// Method handles comma separated team goal ids from collection and creates individual object for each team goal and add in collection. /// </summary> /// <param name="teamGoalStatuses">Collection of team goal status containing not started/in progress/completed status counts for each aligned team goal</param> /// <returns>Returns collection of team goal status containing goal status data about each aligned team goal.</returns> private IEnumerable <TeamGoalStatus> HandleGoalsWithMultipleTeamGoalsAligned(IEnumerable <TeamGoalStatus> teamGoalStatuses) { if (!teamGoalStatuses.Any(teamGoalStatus => teamGoalStatus.TeamGoalId.Contains(',', StringComparison.OrdinalIgnoreCase))) { return(teamGoalStatuses); } var teamGoalStatusDetails = teamGoalStatuses.Where(teamGoalStatus => !teamGoalStatus.TeamGoalId.Contains(',', StringComparison.OrdinalIgnoreCase)).ToList(); var multipleTeamGoalStatuses = teamGoalStatuses.Where(teamGoalStatus => teamGoalStatus.TeamGoalId.Contains(',', StringComparison.OrdinalIgnoreCase)).ToList(); foreach (var teamGoalStatus in multipleTeamGoalStatuses) { var teamgoalIds = teamGoalStatus.TeamGoalId.Split(','); foreach (var teamGoalId in teamgoalIds) { var teamGoalStatusDetail = teamGoalStatusDetails.Where(teamGoalStatus => teamGoalStatus.TeamGoalId == teamGoalId.Trim()).FirstOrDefault(); if (teamGoalStatusDetail != null) { // If team goal id already exists in collection, then add status counts to existing team goal id. teamGoalStatusDetails.ForEach(teamGoalStatusDetail => { if (teamGoalStatusDetail.TeamGoalId == teamGoalId) { teamGoalStatusDetail.NotStartedGoalCount += teamGoalStatus.NotStartedGoalCount; teamGoalStatusDetail.InProgressGoalCount += teamGoalStatus.InProgressGoalCount; teamGoalStatusDetail.CompletedGoalCount += teamGoalStatus.CompletedGoalCount; } }); } else { // Create new object for current team goal id, add status counts and add object in collection. TeamGoalStatus goalStatusDetail = new TeamGoalStatus { NotStartedGoalCount = teamGoalStatus.NotStartedGoalCount, InProgressGoalCount = teamGoalStatus.InProgressGoalCount, CompletedGoalCount = teamGoalStatus.CompletedGoalCount, TeamGoalId = teamGoalId.Trim(), }; teamGoalStatusDetails.Add(goalStatusDetail); } } } return(teamGoalStatusDetails); }
/// <summary> /// Get user team goal status details card for viewing all user status details. /// </summary> /// <param name="teamGoalStatus">Team goal status for each team goal.</param> /// <param name="applicationBasePath">Application base URL.</param> /// <param name="id">Unique id for each row.</param> /// <param name="localizer">The current cultures' string localizer.</param> /// <returns>Returns individual goal card as attachment.</returns> public static List <AdaptiveElement> GetIndividualTeamGoalStatus(TeamGoalStatus teamGoalStatus, string applicationBasePath, int id, IStringLocalizer <Strings> localizer) { teamGoalStatus = teamGoalStatus ?? throw new ArgumentNullException(nameof(teamGoalStatus)); var notStartedStatusCount = teamGoalStatus.NotStartedGoalCount == null ? 0 : teamGoalStatus.NotStartedGoalCount; var inProgressStatusCount = teamGoalStatus.InProgressGoalCount == null ? 0 : teamGoalStatus.InProgressGoalCount; var completedStatusCount = teamGoalStatus.CompletedGoalCount == null ? 0 : teamGoalStatus.CompletedGoalCount; var totalStatusCount = notStartedStatusCount + inProgressStatusCount + completedStatusCount; string cardContent = $"CardContent{id}"; string chevronUp = $"ChevronUp{id}"; string chevronDown = $"ChevronDown{id}"; List <AdaptiveElement> individualTeamGoalStatus = new List <AdaptiveElement> { new AdaptiveColumnSet { Spacing = AdaptiveSpacing.Medium, Columns = new List <AdaptiveColumn> { new AdaptiveColumn { VerticalContentAlignment = AdaptiveVerticalContentAlignment.Center, Width = AdaptiveColumnWidth.Stretch, Items = new List <AdaptiveElement> { new AdaptiveTextBlock { HorizontalAlignment = AdaptiveHorizontalAlignment.Left, Text = string.IsNullOrEmpty(teamGoalStatus.TeamGoalName) ? localizer.GetString("GoalStatusDeletedText") : teamGoalStatus.TeamGoalName, Wrap = true, }, }, }, new AdaptiveColumn { VerticalContentAlignment = AdaptiveVerticalContentAlignment.Center, Width = AdaptiveColumnWidth.Stretch, Items = new List <AdaptiveElement> { new AdaptiveTextBlock { HorizontalAlignment = AdaptiveHorizontalAlignment.Right, Spacing = AdaptiveSpacing.None, Text = string.Format(CultureInfo.InvariantCulture, localizer.GetString("GoalStatusAlignedText"), totalStatusCount), Wrap = true, }, }, }, new AdaptiveColumn { Id = chevronDown, VerticalContentAlignment = AdaptiveVerticalContentAlignment.Center, Width = AdaptiveColumnWidth.Auto, Items = new List <AdaptiveElement> { new AdaptiveImage { AltText = localizer.GetString("GoalStatusChevronDownImageAltText"), PixelWidth = 16, PixelHeight = 8, SelectAction = new AdaptiveToggleVisibilityAction { Title = localizer.GetString("GoalStatusChevronDownImageAltText"), Type = "Action.ToggleVisibility", TargetElements = new List <AdaptiveTargetElement> { cardContent, chevronUp, chevronDown, }, }, Style = AdaptiveImageStyle.Default, Url = new Uri(applicationBasePath + "/Artifacts/chevronDown.png"), HorizontalAlignment = AdaptiveHorizontalAlignment.Right, }, }, }, new AdaptiveColumn { Id = chevronUp, IsVisible = false, VerticalContentAlignment = AdaptiveVerticalContentAlignment.Center, Width = AdaptiveColumnWidth.Auto, Items = new List <AdaptiveElement> { new AdaptiveImage { AltText = localizer.GetString("GoalStatusChevronUpImageAltText"), PixelWidth = 16, PixelHeight = 8, SelectAction = new AdaptiveToggleVisibilityAction { Title = localizer.GetString("GoalStatusChevronUpImageAltText"), Type = "Action.ToggleVisibility", TargetElements = new List <AdaptiveTargetElement> { cardContent, chevronUp, chevronDown, }, }, Style = AdaptiveImageStyle.Default, Url = new Uri(applicationBasePath + "/Artifacts/chevronUp.png"), HorizontalAlignment = AdaptiveHorizontalAlignment.Right, }, }, }, }, }, new AdaptiveContainer { Id = cardContent, IsVisible = false, Style = AdaptiveContainerStyle.Emphasis, Items = new List <AdaptiveElement> { new AdaptiveColumnSet { Spacing = AdaptiveSpacing.None, Columns = new List <AdaptiveColumn> { new AdaptiveColumn { VerticalContentAlignment = AdaptiveVerticalContentAlignment.Center, Width = AdaptiveColumnWidth.Stretch, Items = new List <AdaptiveElement> { new AdaptiveTextBlock { HorizontalAlignment = AdaptiveHorizontalAlignment.Center, Spacing = AdaptiveSpacing.None, Text = localizer.GetString("GoalStatusNotStartedHeader"), Wrap = true, }, }, }, new AdaptiveColumn { VerticalContentAlignment = AdaptiveVerticalContentAlignment.Center, Width = AdaptiveColumnWidth.Stretch, Items = new List <AdaptiveElement> { new AdaptiveTextBlock { HorizontalAlignment = AdaptiveHorizontalAlignment.Center, Spacing = AdaptiveSpacing.None, Text = localizer.GetString("GoalStatusInProgressHeader"), Wrap = true, }, }, }, new AdaptiveColumn { VerticalContentAlignment = AdaptiveVerticalContentAlignment.Center, Width = AdaptiveColumnWidth.Stretch, Items = new List <AdaptiveElement> { new AdaptiveTextBlock { HorizontalAlignment = AdaptiveHorizontalAlignment.Center, Spacing = AdaptiveSpacing.None, Text = localizer.GetString("GoalStatusCompletedHeader"), Wrap = true, }, }, }, new AdaptiveColumn { VerticalContentAlignment = AdaptiveVerticalContentAlignment.Center, Width = AdaptiveColumnWidth.Stretch, Items = new List <AdaptiveElement> { new AdaptiveTextBlock { HorizontalAlignment = AdaptiveHorizontalAlignment.Center, Spacing = AdaptiveSpacing.None, Text = localizer.GetString("GoalStatusTotalHeader"), Wrap = true, }, }, }, }, }, new AdaptiveColumnSet { Spacing = AdaptiveSpacing.None, Columns = new List <AdaptiveColumn> { new AdaptiveColumn { VerticalContentAlignment = AdaptiveVerticalContentAlignment.Center, Width = AdaptiveColumnWidth.Stretch, Items = new List <AdaptiveElement> { new AdaptiveTextBlock { HorizontalAlignment = AdaptiveHorizontalAlignment.Center, Spacing = AdaptiveSpacing.None, Text = notStartedStatusCount.ToString(), Wrap = true, }, }, }, new AdaptiveColumn { VerticalContentAlignment = AdaptiveVerticalContentAlignment.Center, Width = AdaptiveColumnWidth.Stretch, Items = new List <AdaptiveElement> { new AdaptiveTextBlock { HorizontalAlignment = AdaptiveHorizontalAlignment.Center, Spacing = AdaptiveSpacing.None, Text = inProgressStatusCount.ToString(), Wrap = true, }, }, }, new AdaptiveColumn { VerticalContentAlignment = AdaptiveVerticalContentAlignment.Center, Width = AdaptiveColumnWidth.Stretch, Items = new List <AdaptiveElement> { new AdaptiveTextBlock { HorizontalAlignment = AdaptiveHorizontalAlignment.Center, Spacing = AdaptiveSpacing.None, Text = completedStatusCount.ToString(), Wrap = true, }, }, }, new AdaptiveColumn { VerticalContentAlignment = AdaptiveVerticalContentAlignment.Center, Width = AdaptiveColumnWidth.Stretch, Items = new List <AdaptiveElement> { new AdaptiveTextBlock { HorizontalAlignment = AdaptiveHorizontalAlignment.Center, Spacing = AdaptiveSpacing.None, Text = totalStatusCount.ToString(), Wrap = true, }, }, }, }, }, }, }, }; return(individualTeamGoalStatus); }