private async Task CouQueryComplete(IDialogContext context, IAwaitable <CouQueryForm> result) { CouQueryForm form = null; try { form = await result; } catch (OperationCanceledException) { } if (form != null) { List <Course> courses = Database2.GetCourse(form.CourseName); if (courses == null || courses.Count == 0) { await context.PostAsync($"Sorry, could not find Course for {form.CourseName} "); return; } StringBuilder sb2 = new StringBuilder(); sb2.Append($"Hi There! I was able to find **{courses.Count.ToString()}** Courses \n\n"); sb2.Append("--\n\n"); foreach (Course course in courses) { sb2.Append($"Course ID is **{course.CourseID}**;\n Course Name is **{course.CourseName}**;\n Course Department is **{course.Department}**; \n Course Level is **{course.Level}**;\n Course Intake is **{course.Intake}**; \n Course will have **{course.Assignments}** Assignments; \n Course is divided in following way \n Attendance **{course.Attendance}** %; \n Class Participation **{course.CP}** %; \n Exam 1 **{course.Exam1}** %; \n Exam2 **{course.Exam2}** %; \n Project **{course.Project}**; \n HomeWork **{course.HW}**%"); } var message = $"Looking for courses {form.CourseName} "; // var message1 = $"Looking for students {form.courseID}"; await context.PostAsync(sb2.ToString()); } context.Wait(MessageReceived); }