Пример #1
0
        /// <summary>
        /// Get the goal status card in channel.
        /// </summary>
        /// <param name="teamGoalStatuses">Team goal status for each team goal.</param>
        /// <param name="teamGoalStartDate">Team goal start date for team goal cycle.</param>
        /// <param name="teamGoalEndDate">Team goal end date for team goal cycle.</param>
        /// <param name="applicationBasePath">Application base URL.</param>
        /// <param name="localizer">The current cultures' string localizer.</param>
        /// <returns>Goal status card as attachment in teams channel.</returns>
        public static Attachment GetGoalStatusCard(IEnumerable <TeamGoalStatus> teamGoalStatuses, string teamGoalStartDate, string teamGoalEndDate, string applicationBasePath, IStringLocalizer <Strings> localizer)
        {
            var          startDate      = CardHelper.FormatDateStringToAdaptiveCardDateFormat(teamGoalStartDate);
            var          endDate        = CardHelper.FormatDateStringToAdaptiveCardDateFormat(teamGoalEndDate);
            AdaptiveCard goalStatusCard = new AdaptiveCard(Constants.AdaptiveCardVersion)
            {
                Height         = AdaptiveHeight.Stretch,
                PixelMinHeight = 150,
                Body           = new List <AdaptiveElement>
                {
                    new AdaptiveColumnSet
                    {
                        Columns = new List <AdaptiveColumn>
                        {
                            new AdaptiveColumn
                            {
                                VerticalContentAlignment = AdaptiveVerticalContentAlignment.Center,
                                Width = AdaptiveColumnWidth.Auto,
                                Items = new List <AdaptiveElement>
                                {
                                    new AdaptiveTextBlock
                                    {
                                        HorizontalAlignment = AdaptiveHorizontalAlignment.Left,
                                        Text   = localizer.GetString("GoalStatusCardTitle"),
                                        Weight = AdaptiveTextWeight.Bolder,
                                        Size   = AdaptiveTextSize.Large,
                                        Wrap   = true,
                                    },
                                },
                            },
                        },
                    },
                    new AdaptiveColumnSet
                    {
                        Columns = new List <AdaptiveColumn>
                        {
                            new AdaptiveColumn
                            {
                                VerticalContentAlignment = AdaptiveVerticalContentAlignment.Center,
                                Width = AdaptiveColumnWidth.Auto,
                                Items = new List <AdaptiveElement>
                                {
                                    new AdaptiveTextBlock
                                    {
                                        HorizontalAlignment = AdaptiveHorizontalAlignment.Left,
                                        Text = localizer.GetString("GoalStatusGoalCycleText"),
                                        Wrap = true,
                                    },
                                },
                            },
                            new AdaptiveColumn
                            {
                                VerticalContentAlignment = AdaptiveVerticalContentAlignment.Center,
                                Width = AdaptiveColumnWidth.Stretch,
                                Items = new List <AdaptiveElement>
                                {
                                    new AdaptiveTextBlock
                                    {
                                        HorizontalAlignment = AdaptiveHorizontalAlignment.Left,
                                        Text   = $"{startDate} - {endDate}",
                                        Wrap   = true,
                                        Weight = AdaptiveTextWeight.Bolder,
                                    },
                                },
                            },
                        },
                    },
                    new AdaptiveColumnSet
                    {
                        Columns = new List <AdaptiveColumn>
                        {
                            new AdaptiveColumn
                            {
                                Width = AdaptiveColumnWidth.Stretch,
                                Items = new List <AdaptiveElement>
                                { // Represents empty column required for alignment.
                                },
                            },
                        },
                    },
                },
            };

            List <AdaptiveElement> teamGoalStatusList = GetAllTeamGoalStatuses(teamGoalStatuses, applicationBasePath, localizer);

            goalStatusCard.Body.AddRange(teamGoalStatusList);

            var card = new Attachment()
            {
                ContentType = AdaptiveCard.ContentType,
                Content     = goalStatusCard,
            };

            return(card);
        }
Пример #2
0
        /// <summary>
        /// Gets the add note submit card.
        /// </summary>
        /// <param name="personalGoalNoteDetail">Instance containing personal goal note related details.</param>
        /// <param name="personalGoalDetail">Instance containing personal goal related details.</param>
        /// <param name="localizer">The current cultures' string localizer.</param>
        /// <returns>Attachment having add note submit card.</returns>
        public static Attachment GetsAddNoteSubmitCard(PersonalGoalNoteDetail personalGoalNoteDetail, PersonalGoalDetail personalGoalDetail, IStringLocalizer <Strings> localizer)
        {
            personalGoalDetail     = personalGoalDetail ?? throw new ArgumentNullException(nameof(personalGoalDetail));
            personalGoalNoteDetail = personalGoalNoteDetail ?? throw new ArgumentNullException(nameof(personalGoalNoteDetail));
            var isSourceEmpty = string.IsNullOrEmpty(personalGoalNoteDetail?.SourceName) ? true : false;

            AdaptiveCard addCardSubmitCard = new AdaptiveCard(Constants.AdaptiveCardVersion)
            {
                Body = new List <AdaptiveElement>()
                {
                    new AdaptiveTextBlock
                    {
                        Text   = localizer.GetString("AddNoteHeading"),
                        Weight = AdaptiveTextWeight.Bolder,
                        Size   = AdaptiveTextSize.Large,
                        Wrap   = true,
                    },
                    new AdaptiveColumnSet
                    {
                        Spacing = AdaptiveSpacing.Padding,
                        Columns = new List <AdaptiveColumn>
                        {
                            new AdaptiveColumn
                            {
                                Width = "1",
                                Items = new List <AdaptiveElement>
                                {
                                    new AdaptiveTextBlock
                                    {
                                        Size = AdaptiveTextSize.Medium,
                                        Wrap = true,
                                        Text = localizer.GetString("AddNoteGoalNameSubheading"),
                                    },
                                },
                            },
                            new AdaptiveColumn
                            {
                                Width = "4",
                                Items = new List <AdaptiveElement>
                                {
                                    new AdaptiveTextBlock
                                    {
                                        Size   = AdaptiveTextSize.Medium,
                                        Wrap   = true,
                                        Text   = personalGoalDetail.GoalName,
                                        Weight = AdaptiveTextWeight.Bolder,
                                    },
                                },
                            },
                        },
                    },
                    new AdaptiveColumnSet
                    {
                        Spacing = AdaptiveSpacing.Padding,
                        Columns = new List <AdaptiveColumn>
                        {
                            new AdaptiveColumn
                            {
                                Width = "1",
                                Items = new List <AdaptiveElement>
                                {
                                    new AdaptiveTextBlock
                                    {
                                        Size   = AdaptiveTextSize.Medium,
                                        Wrap   = true,
                                        Text   = localizer.GetString("AddNoteNoteSubheading"),
                                        Weight = AdaptiveTextWeight.Bolder,
                                    },
                                },
                            },
                            new AdaptiveColumn
                            {
                                Width = "4",
                                Items = new List <AdaptiveElement>
                                {
                                    new AdaptiveTextBlock
                                    {
                                        Size = AdaptiveTextSize.Medium,
                                        Wrap = true,
                                        Text = personalGoalNoteDetail.PersonalGoalNoteDescription,
                                    },
                                },
                            },
                        },
                    },
                },
            };

            if (!isSourceEmpty)
            {
                addCardSubmitCard.Body.Add(new AdaptiveColumnSet()
                {
                    Spacing = AdaptiveSpacing.None,
                    Columns = new List <AdaptiveColumn>
                    {
                        new AdaptiveColumn
                        {
                            Width = "1",
                            Items = new List <AdaptiveElement>
                            {
                                new AdaptiveTextBlock
                                {
                                    Size   = AdaptiveTextSize.Medium,
                                    Wrap   = true,
                                    Text   = localizer.GetString("AddNoteSourceSubheading"),
                                    Weight = AdaptiveTextWeight.Bolder,
                                },
                            },
                        },
                        new AdaptiveColumn
                        {
                            Width = "4",
                            Items = new List <AdaptiveElement>
                            {
                                new AdaptiveTextBlock
                                {
                                    Size = AdaptiveTextSize.Medium,
                                    Wrap = true,
                                    Text = personalGoalNoteDetail.SourceName,
                                },
                            },
                        },
                    },
                });
            }

            addCardSubmitCard.Body.Add(new AdaptiveColumnSet()
            {
                Spacing = AdaptiveSpacing.None,
                Columns = new List <AdaptiveColumn>
                {
                    new AdaptiveColumn
                    {
                        Width = "1",
                        Items = new List <AdaptiveElement>
                        {
                            new AdaptiveTextBlock
                            {
                                Size   = AdaptiveTextSize.Medium,
                                Wrap   = true,
                                Text   = localizer.GetString("AddNoteDateSubheading"),
                                Weight = AdaptiveTextWeight.Bolder,
                            },
                        },
                    },
                    new AdaptiveColumn
                    {
                        Width = "4",
                        Items = new List <AdaptiveElement>
                        {
                            new AdaptiveTextBlock
                            {
                                Size = AdaptiveTextSize.Medium,
                                Wrap = true,
                                Text = CardHelper.FormatDateStringToAdaptiveCardDateFormat(DateTime.Now.ToString(CultureInfo.CurrentCulture)),
                            },
                        },
                    },
                },
            });

            addCardSubmitCard.Actions = new List <AdaptiveAction>
            {
                new AdaptiveSubmitAction
                {
                    Title = localizer.GetString("AddNoteEditButtonText"),
                    Data  = new AdaptiveSubmitActionData
                    {
                        MsTeams = new TaskModuleAction(
                            localizer.GetString("AddNoteEditButtonText"),
                            new
                        {
                            data = JsonConvert.SerializeObject(new AdaptiveSubmitActionData
                            {
                                AdaptiveActionType = Constants.EditNoteCommand,
                                PersonalGoalNoteId = personalGoalNoteDetail.PersonalGoalNoteId,
                                PersonalGoalId     = personalGoalNoteDetail.PersonalGoalId,
                                GoalNoteId         = personalGoalNoteDetail.AdaptiveCardActivityId,
                            }),
                        }),
                    },
                },
            };

            return(new Attachment
            {
                ContentType = AdaptiveCard.ContentType,
                Content = addCardSubmitCard,
            });
        }