protected override SimpleResponse Respond(AliceRequest request, State state) { using var db = new DatabaseContext(); Parser.Parser s = new Parser.Parser(); var raspisanie = s.getRasp(db.Users.Find(request.Session.UserId).group); // var raspisanie = s.getRasp("3256"); string str = " пока что у вас нет пар"; bool brak = false; foreach (var day in raspisanie) { foreach (var lesson in day.lessons) { if (lesson.Value != "" && lesson.Value != "-" && DateTime.Today.CompareTo(RightDate(day.date)) == -1) { str = lesson.Key + " " + lesson.Value + " " + day.date; brak = true; goto poprtak; } } } poprtak: return(new SimpleResponse { Text = str }); }
protected override SimpleResponse Respond(AliceRequest request, State state) { using var db = new DatabaseContext(); Parser.Parser s = new Parser.Parser(); var raspisanie = s.getRasp(db.Users.Find(request.Session.UserId).group); string str = ""; var today = DateTime.Today.DayOfWeek.ToString(); int todaysId = 0; switch (today.ToLower()) { case "monday": todaysId = 0; break; case "tuesday": todaysId = 1; break; case "wednesday": todaysId = 2; break; case "thursday": todaysId = 3; break; case "friday": todaysId = 4; break; case "saturday": todaysId = 5; break; case "sunday": todaysId = 6; break; } foreach (var lesson in raspisanie[todaysId].lessons) { if (lesson.Value != "" && lesson.Value != "-") { str = str + "В " + lesson.Key + " " + lesson.Value + " \n"; } } if (str == "") { return new SimpleResponse { Text = "Сегодня у вас нет занятий" } } ; else { return new SimpleResponse { Text = "Сегодня у вас \n" + str } }; } }
protected override SimpleResponse Respond(AliceRequest request, State state) { using var db = new DatabaseContext(); Parser.Parser s = new Parser.Parser(); var raspisanie = s.getRasp(db.Users.Find(request.Session.UserId).group); int requestDaysId = 0; string str = ""; var day = request.Request.Nlu.Tokens[request.Request.Nlu.Tokens.Count - 1]; if (request.Request.Command.Contains("следующ")) { switch (day) { case "понедельник": requestDaysId = 7; foreach (var lesson in raspisanie[7].lessons) { if (lesson.Value != "" && lesson.Value != "-") { str = str + "В " + lesson.Key + " " + lesson.Value + " \n"; } } break; case "вторник": requestDaysId = 8; foreach (var lesson in raspisanie[8].lessons) { if (lesson.Value != "" && lesson.Value != "-") { str = str + "В " + lesson.Key + " " + lesson.Value + " \n"; } } break; case "среду": requestDaysId = 9; foreach (var lesson in raspisanie[9].lessons) { if (lesson.Value != "" && lesson.Value != "-") { str = str + "В " + lesson.Key + " " + lesson.Value + " \n"; } } break; case "четверг": requestDaysId = 10; foreach (var lesson in raspisanie[10].lessons) { if (lesson.Value != "" && lesson.Value != "-") { str = str + "В " + lesson.Key + " " + lesson.Value + " \n"; } } break; case "пятницу": requestDaysId = 11; foreach (var lesson in raspisanie[11].lessons) { if (lesson.Value != "" && lesson.Value != "-") { str = str + "В " + lesson.Key + " " + lesson.Value + " \n"; } } break; case "субботу": requestDaysId = 12; foreach (var lesson in raspisanie[12].lessons) { if (lesson.Value != "" && lesson.Value != "-") { str = str + "В " + lesson.Key + " " + lesson.Value + " \n"; } } break; case "воскресенье": requestDaysId = 13; str = " в этот день у вас нет пар"; break; case "воскресение": requestDaysId = 13; str = " в этот день у вас нет пар"; break; } } else { switch (day) { case "понедельник": requestDaysId = 0; foreach (var lesson in raspisanie[0].lessons) { if (lesson.Value != "" && lesson.Value != "-") { str = str + "В " + lesson.Key + " " + lesson.Value + " \n"; } } break; case "вторник": requestDaysId = 1; foreach (var lesson in raspisanie[1].lessons) { if (lesson.Value != "" && lesson.Value != "-") { str = str + "В " + lesson.Key + " " + lesson.Value + " \n"; } } break; case "среду": requestDaysId = 2; foreach (var lesson in raspisanie[2].lessons) { if (lesson.Value != "" && lesson.Value != "-") { str = str + "В " + lesson.Key + " " + lesson.Value + " \n"; } } break; case "четверг": requestDaysId = 3; foreach (var lesson in raspisanie[3].lessons) { if (lesson.Value != "" && lesson.Value != "-") { str = str + "В " + lesson.Key + " " + lesson.Value + " \n"; } } break; case "пятницу": requestDaysId = 4; foreach (var lesson in raspisanie[4].lessons) { if (lesson.Value != "" && lesson.Value != "-") { str = str + "В " + lesson.Key + " " + lesson.Value + " \n"; } } break; case "субботу": requestDaysId = 5; foreach (var lesson in raspisanie[5].lessons) { if (lesson.Value != "" && lesson.Value != "-") { str = str + "В " + lesson.Key + " " + lesson.Value + " \n"; } } break; case "воскресенье": requestDaysId = 6; foreach (var lesson in raspisanie[6].lessons) { if (lesson.Value != "" && lesson.Value != "-") { str = str + "В " + lesson.Key + " " + lesson.Value + " \n"; } } break; case "воскресение": requestDaysId = 6; foreach (var lesson in raspisanie[6].lessons) { if (lesson.Value != "" && lesson.Value != "-") { str = str + "В " + lesson.Key + " " + lesson.Value + " \n"; } } break; } } var today = DateTime.Today.DayOfWeek.ToString(); int todaysId = 0; switch (today.ToLower()) { case "monday": todaysId = 0; break; case "tuesday": todaysId = 1; break; case "wednesday": todaysId = 2; break; case "thursday": todaysId = 3; break; case "friday": todaysId = 4; break; case "saturday": todaysId = 5; break; case "sunday": todaysId = 6; break; } if (requestDaysId == todaysId) { if (str == "") { return new SimpleResponse { Text = "В " + day + " у вас нет пар" } } ; else { return new SimpleResponse { Text = "Если вы про сегодня, \n" + str } }; } else { if (str == "") { return new SimpleResponse { Text = "В " + day + " у вас нет пар" } } ; else { return new SimpleResponse { Text = "В " + day + " у вас \n" + str } }; } } }