Exemplo n.º 1
0
        public GalleryCard GetGalleryCard(Guid OptionId)
        {
            OptionCardModel cardResult = (from opt in _db.Options
                                          where opt.OptionId == OptionId
                                          select new OptionCardModel()
            {
                Title = opt.Title,
                Description = opt.Body,
                OptionId = opt.OptionId,
                ParentOptionId = opt.ParentOptionId,
                Result = opt.Result,
                Options = (from opt2 in _db.Options where opt2.ParentOptionId == opt.OptionId select opt2).ToList()
            }).SingleOrDefault();

            var galleryCard = new GalleryCard();

            galleryCard.BotName     = "Brainy";
            galleryCard.Title       = cardResult.Title;
            galleryCard.UrlImage    = "http://localhost:3978/img/bot-avatar_5.png";
            galleryCard.Description = cardResult.Description;

            var listActions = GetListActions(cardResult.Options);

            galleryCard.Actions.AddRange(listActions);

            return(galleryCard);
        }
Exemplo n.º 2
0
        public WelcomeCardSimple GetWelcomeCard()
        {
            var randomizer = new Random();

            OptionCardModel cardResult = (from opt in _db.Options
                                          where opt.Type == "WELCOME"
                                          let rand = randomizer.Next()
                                                     orderby rand
                                                     select new OptionCardModel()
            {
                Title = opt.Title,
                Description = opt.Body,
                OptionId = opt.OptionId,
                ParentOptionId = opt.ParentOptionId,
                Result = opt.Result,
                Options = (from opt2 in _db.Options where opt2.ParentOptionId == opt.OptionId select opt2).ToList()
            }).Take(1).SingleOrDefault();



            var welcomeCard = new WelcomeCardSimple();

            welcomeCard.BotName     = "Brainy";
            welcomeCard.Title       = cardResult.Title;
            welcomeCard.UrlImage    = "http://localhost:3978/img/bot-avatar_4.png";
            welcomeCard.Description = cardResult.Description;

            var listActions = GetListActions(cardResult.Options);

            welcomeCard.Actions.AddRange(listActions);

            return(welcomeCard);
        }