public void ShowGroupTimetable(Context context, Result result) { var user = context.SharedData.OfType <User>(); context.SharedData.Remove(user); MessageTransfer msg = new MessageTransfer() { ChatId = user.Id }; var group = result.Entities.OfType("groupName"); var day = result.Entities.OfType <DateEntity>(Sys.Date) ?? new DateEntity("", DateTime.Now); int groupId = -1; try { groupId = CistApi.GetGroupIdFromName(group.Value); } catch (Exception) { msg.Message = "Что-то я не нашел такой группы, попробуй ещё раз!"; result.SendResponse(msg.ToJson()); return; } DayTimetable timetable = CistApi.GetGroupTimetable(groupId, day.DateTime); msg.Message = timetable?.ToString() ?? $"В расписании нету пар на {day.DateTime.ToShortDateString()}"; result.SendResponse(msg.ToJson()); }
public void ShowTodayTimetable(Context context, Result result) { var user = context.SharedData.OfType <User>(); context.SharedData.Remove(user); MessageTransfer msg = new MessageTransfer() { ChatId = user.Id }; DayTimetable timetable = new DayTimetable(); switch (user.Role) { case Role.Student: timetable = CistApi.GetGroupTimetable((user as Student).GroupId, DateTime.Now); break; case Role.Teacher: timetable = CistApi.GetTeacherTimetable((user as Teacher).TeacherId, DateTime.Now); break; default: break; } msg.Message = timetable?.ToString() ?? "На сегодня пар нету!"; result.SendResponse(msg.ToJson()); }
public void ShowNextDayTimetable(Context context, Result result) { var user = context.SharedData.OfType <User>(); context.SharedData.Remove(user); MessageTransfer msg = new MessageTransfer() { ChatId = user.Id }; var day = result.Entities.OfType <DateEntity>(Sys.Date); DayTimetable timetable = new DayTimetable(); switch (user.Role) { case Role.Student: timetable = CistApi.GetGroupTimetable((user as Student).GroupId, day.DateTime); break; case Role.Teacher: timetable = CistApi.GetTeacherTimetable((user as Teacher).TeacherId, day.DateTime); break; default: break; } msg.Message = timetable?.ToString() ?? $"В расписании нету пар на {day.DateTime.ToShortDateString()}"; result.SendResponse(msg.ToJson()); }
public void ShowTeacherTimetable(Context context, Result result) { var user = context.SharedData.OfType <User>(); context.SharedData.Remove(user); MessageTransfer msg = new MessageTransfer() { ChatId = user.Id }; var teacher = result.Entities.OfType("teacherName"); var day = result.Entities.OfType <DateEntity>(Sys.Date); int teacherId = -1; try { teacherId = CistApi.GetTeacherIdFromName(teacher.Value); } catch (Exception) { msg.Message = "Что-то я не нашел такого преподователя, попробуй ещё раз!"; result.SendResponse(msg.ToJson()); return; } DayTimetable timetable = CistApi.GetTeacherTimetable(teacherId, day.DateTime); msg.Message = timetable?.ToString() ?? $"В расписании нету пар на {day.DateTime.ToShortDateString()}"; result.SendResponse(msg.ToJson()); }