Пример #1
0
        private ImageCardContext CreateImageContext(PickerItem cardPickerItem, Attachment attachment)
        {
            HeroCard         card         = JsonConvert.DeserializeObject <HeroCard>(attachment.Content.ToString());
            ImageCardContext imageContext = new ImageCardContext();

            if (card.Images != null && card.Images.Count > 0)
            {
                imageContext.Image = card.Images[0].Url;
            }
            imageContext.Title       = card.Title;
            imageContext.Subtitle    = card.Subtitle;
            imageContext.Description = card.Text;

            foreach (CardAction action in card.Buttons)
            {
                CardAction        currentAction = action;
                CardActionContext actionContext = new CardActionContext()
                {
                    Text    = currentAction.Title,
                    Command = new Command(() =>
                    {
                        this.chat.Items.Remove(cardPickerItem);
                        this.chat.Items.Add(new TextMessage()
                        {
                            Author = this.chat.Author, Text = currentAction.Value.ToString()
                        });
                    })
                };

                imageContext.Actions.Add(actionContext);
            }

            return(imageContext);
        }
Пример #2
0
        private ICollection <CardActionContext> GetActions(ChatItem chatItem, string Title)
        {
            var selectAction = new CardActionContext
            {
                Text    = "Select",
                Command = new Command(() =>
                {
                    var index = chat.Items.IndexOf(chatItem);
                    chat.Items.RemoveAt(index);
                    chat.Items.Add(new TextMessage {
                        Author = this.chat.Author, Text = Title
                    });
                })
            };

            var seeBioAction = new CardActionContext
            {
                Text    = "See Bio",
                Command = new Command(() =>
                {
                    var index = chat.Items.IndexOf(chatItem);
                    chat.Items.RemoveAt(index);
                    chat.Items.Add(new TextMessage {
                        Author = this.chat.Author, Text = Title + " biography"
                    });
                })
            };

            return(new List <CardActionContext>()
            {
                selectAction, seeBioAction
            });
        }
Пример #3
0
 public CardRepository(CardContext context,
                       CardActionContext cardActionContext,
                       BoardContext boardContext, ColumnContext columnContext,
                       TodolistContext todolistContext)
 {
     _db                = context;
     _dbBoard           = boardContext;
     _dbColumn          = columnContext;
     _todolistContext   = todolistContext;
     _cardActionContext = cardActionContext;
 }
 public CardActionRepository(CardActionContext db, CardContext cc)
 {
     _dbCards = cc;
     _db      = db;
 }