/// <summary> /// Asks the user to choose some course. /// </summary> /// <param name="stepContext"></param> /// <param name="cancellationToken"></param> /// <returns></returns> private async Task <DialogTurnResult> AskCourseStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var _DialogInfo = await _dialogInfoStateProperty.GetAsync(stepContext.Context); _DialogInfo.LastDialogName = this.Id; var courses = DecisionMaker.GetCourses(_DialogInfo.Language); { var choices = new List <Choice>(); foreach (var course in courses) { choices.Add(new Choice(course.Name)); } var dialogsMUI = DecisionMaker.GetDialogsMui(_DialogInfo.Language); var prompt = dialogsMUI.CoursesDictionary["prompt"];// "What you are interested in?"; var reprompt = dialogsMUI.CoursesDictionary["reprompt"]; var options = new PromptOptions() { Prompt = MessageFactory.Text(prompt), RetryPrompt = MessageFactory.Text(reprompt), Choices = choices, Style = ListStyle.SuggestedAction//.HeroCard }; var message = options.Prompt.Text; var sender = "bot"; var time = stepContext.Context.Activity.Timestamp.Value; _myLogger.LogMessage(message, sender, time, _DialogInfo.DialogId); return(await stepContext.PromptAsync(nameof(ChoicePrompt), options, cancellationToken)); } }
public async Task Get() { var courses = _db.Courses.Where(s => s.RegistrationStartDate.ToShortDateString() == DateTime.Today.ToShortDateString()); if (courses.Any()) { foreach (var course in courses) { // This is for notification on email and chat var matchedCourses = _db.UserCourses.Where(item => item.CourseId == course.Id); if (matchedCourses.Any()) { foreach (var matchedCourse in matchedCourses) { var user = _db.User.First(u => u.Id == matchedCourse.UserId); if (!matchedCourse.Notified) { var language = user.Language; var dialogsMUI = _decisionMaker.GetDialogsMui(language); var courseByName = _decisionMaker.GetCourses(language) .First(item => item.Name == matchedCourse.Course.Name); var msg = $"<h3>{dialogsMUI.SubscriptionDictionary["title"]}</h3> <br>" + $"<h5>{dialogsMUI.SubscriptionDictionary["info"]} {matchedCourse.Course.Name}," + $" {dialogsMUI.SubscriptionDictionary["registrationStarts"]} {matchedCourse.Course.RegistrationStartDate.ToShortDateString()}" + $" {dialogsMUI.SubscriptionDictionary["courseStarts"]} {matchedCourse.Course.StartDate.ToShortDateString()}. <br> </h5>" + $"{courseByName.Resources}"; // Notifying into the chat if (!string.IsNullOrEmpty(user.ConversationReference)) { message = $"**{dialogsMUI.SubscriptionDictionary["subject"]}**\n\n" + $"{dialogsMUI.SubscriptionDictionary["title"]}\n\n" + $"{dialogsMUI.SubscriptionDictionary["info"]} {matchedCourse.Course.Name}," + $" {dialogsMUI.SubscriptionDictionary["registrationStarts"]} {matchedCourse.Course.RegistrationStartDate.ToShortDateString()}" + $" {dialogsMUI.SubscriptionDictionary["courseStarts"]} {matchedCourse.Course.StartDate.ToShortDateString()}.\n\n" + $"{courseByName.Resources}"; var conversationReference = JsonConvert.DeserializeObject <ConversationReference>(user.ConversationReference); await((BotAdapter)_adapter).ContinueConversationAsync(_appId, conversationReference, BotCallback, default(CancellationToken)); } message = string.Empty; // Notifying into the mail if (!string.IsNullOrEmpty(user.Email)) { await _emailSender.SendEmailAsync(matchedCourse.User.Email, dialogsMUI.SubscriptionDictionary["subject"], msg); } matchedCourse.Notified = true; _db.SaveChanges(); Console.WriteLine("-----------------\n" + "Notification sent!!!\n" + "-----------------"); } } } } } }