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 (NoCurrencyFoundException e) { await context.PostAsync("No such currency found or luis don't get it"); } context.Wait(this.MessageReceived); }
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 (NoCurrencyFoundException e) { await context.PostAsync("No such currency found or Luis don't get it"); } context.Wait(this.MessageReceived); }
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 (NoCurrencyFoundException e) { await context.PostAsync("No such currency found or Luis don't get it"); } }