Ejemplo n.º 1
0
        private static string GetWinnerAnnouncementCard(IHostingEnvironment env, ChannelAccount[] winners)
        {
            var winnerImages = new string[]
            {
                "https://media.giphy.com/media/44gu1V41ejJni/giphy.gif",
                "https://media.giphy.com/media/xUOwGmG2pRfFZUmdVe/giphy.gif",
                "https://media.giphy.com/media/3o7bu57lYhUEFiYDSM/giphy.gif",
                "https://media.giphy.com/media/xTiTnz33weTH3K8Uvu/giphy.gif",
                "https://media.giphy.com/media/ZcUGu59vhBGgbBhh0n/giphy.gif"
            };

            var selectedImage = winnerImages[new Random(Guid.NewGuid().GetHashCode()).Next(winnerImages.Length)];

            var model = new CardReader.AnnouncementCardModel()
            {
                ImageUrl = selectedImage,
                Winners  = new List <CardReader.AnnouncementCardWinner>()
            };

            foreach (var w in winners)
            {
                model.Winners.Add(new CardReader.AnnouncementCardWinner()
                {
                    Name = w.Name,
                    Id   = w.Id,
                });
            }

            var adaptiveCardJson = CardReader.GetAnnouncementCard(env, model);

            return(adaptiveCardJson);
        }