Ejemplo n.º 1
0
        public async Task RemoveCoin(IDialogContext context, IAwaitable <IMessageActivity> activity, LuisResult result)
        {
            var val = result.Entities;

            try
            {
                var t = await CoinMarketCapService.GetTicker(val[1].Entity);

                var count = val[0].Entity;
                if (ConversationStarter.ToPortfolio(t.Id, new Coin("-" + count, t)))
                {
                    await context.PostAsync($"You remove {count} {t.Name} from your Portfolio");
                }
                else
                {
                    await context.PostAsync($"You don't have enough in your portfolio to remuve {count} {t.Name}");
                }
            }
            catch (No​​Currency​​FoundException e)
            {
                await context.PostAsync("No ​​such currency​​ found or luis don't get it");
            }

            context.Wait(this.MessageReceived);
        }
Ejemplo n.º 2
0
        public async Task AddCoin(IDialogContext context, IAwaitable <IMessageActivity> activity, LuisResult result)
        {
            var val = result.Entities;

            //todo:get rid of 2 the same parts of code
            try
            {
                var t = await CoinMarketCapService.GetTicker(val[1].Entity);

                var count = val[0].Entity;
                if (ConversationStarter.ToPortfolio(t.Id, new Coin(count, t)))
                {
                    await context.PostAsync($"You added {count} {t.Name} to your portfolio");
                }
            }
            catch (No​​Currency​​FoundException e)
            {
                await context.PostAsync("No ​​such currency​​ found or Luis don't get it");
            }
            context.Wait(this.MessageReceived);
        }
Ejemplo n.º 3
0
        public virtual async Task AddCoin(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            try
            {
                var message = await result;
                var text    = message.Text;

                var r = Regex.Matches(text, pattern, RegexOptions.IgnoreCase);

                //todo:get rid of 2 the same parts of code
                var t = await CoinMarketCapService.GetTicker(r[1].Value);

                var count = r[0].Value;
                if (ConversationStarter.ToPortfolio(t.Id, new Coin(count, t)))
                {
                    await context.PostAsync($"You added {count} {t.Name} to your portfolio");
                }
            }
            catch (No​​Currency​​FoundException e)
            {
                await context.PostAsync("No ​​such currency​​ found or Luis don't get it");
            }
        }