public virtual async Task ResumeGetFirstName(IDialogContext context, IAwaitable <string> Username) { string response = await Username; firstName = response; if (firstName.Equals("reset", StringComparison.InvariantCultureIgnoreCase)) { context.EndConversation("End"); } else if ((Regex.IsMatch(firstName, @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*")) || (Regex.IsMatch(firstName, @"^[0][1-9]\d{9}$|^[1-9]\d{9}$"))) { string api = "/rest/learning/product/FetchCourseProduct"; var responseFromServer = await _restApiUtil.GetResponseFromServer(api); var serializer = new JavaScriptSerializer(); var courseProductList = serializer.Deserialize <List <CourseProduct> >(responseFromServer); var courseList = courseProductList.Select(x => x.Name).ToList(); PromptDialog.Choice(context, ChildDialogComplete, courseProductList.Select(x => x.Name), "What course are you interested to inquire for?", "Selected course not available. Please try again.", 3, PromptStyle.Auto, courseProductList.Select(x => x.Name)); } else { PromptDialog.Text( context: context, resume: ResumeGetFirstName, prompt: "Kindly share valid email address or contact number", retry: "Sorry, I didn't understand that. Please try again." ); } }
/// <summary> /// Gets phone /// </summary> /// <param name="context"></param> /// <param name="mobile"></param> /// <returns></returns> public async Task ResumeGetPhone(IDialogContext context, IAwaitable <string> mobile) { string response = await mobile; phone = response; if (phone.Equals("reset", StringComparison.InvariantCultureIgnoreCase)) { context.EndConversation("End"); } else if (Regex.IsMatch(phone, @"^[0][1-9]\d{9}$|^[1-9]\d{9}$")) { string api = "/rest/learning/product/FetchDonationProduct"; var responseFromServer = await _restApiUtil.GetResponseFromServer(api); var serializer = new JavaScriptSerializer(); var donationProductList = serializer.Deserialize <List <DonationProduct> >(responseFromServer); PromptDialog.Choice(context, ChildDialogComplete, donationProductList.Select(x => x.Name), "We have number of donation options where you can make real difference. Please Select.", "Selected donation not available. Please try again.", 3, PromptStyle.Auto, donationProductList.Select(x => x.Name)); } else { PromptDialog.Text( context: context, resume: ResumeGetPhone, prompt: "Kindly share valid contact number", retry: "Sorry, I didn't understand that. Please try again." ); } }