public static async Task ShowStores(IDialogContext context, string productId) { var reply = context.MakeMessage(); var storeCollection = DbSingleton.GetDatabase().GetCollection <Store>(AppSettings.StoreCollection); var filter = Builders <Store> .Filter.Empty; List <Store> stores = storeCollection.Find(filter).ToList(); List <Store> storesWStock = new List <Store>(); for (int i = 0; i < stores.Count(); i++) { for (int j = 0; j < stores[i].ProductsInStock.Count(); j++) { if (stores[i].ProductsInStock[j].ProductId.ToString().Equals(productId)) { if (stores[i].ProductsInStock[j].Stock > 0 && storesWStock.Count() <= N_STORES_MAX) { storesWStock.Add(stores[i]); break; } } } } var text = ""; if (storesWStock.Count() == 0) { reply.AttachmentLayout = AttachmentLayoutTypes.List; text = Interactions.getStockFail(); } else { text = Interactions.getStockSuccess(); reply.AttachmentLayout = AttachmentLayoutTypes.Carousel; List <Attachment> cards = new List <Attachment>(); for (var i = 0; i < storesWStock.Count() && i < 7; i++) { cards.Add(StoreCard.GetStoreDetailsCard(storesWStock[i], productId).ToAttachment()); } reply.Attachments = cards; } await Interactions.SendMessage(context, text, 0, 2000); await context.PostAsync(reply); }