private static Lesson ParseSampleLesson() { var lesson = Lessons.LessonLoader.LoadSampleLesson(); var parser = new LessonParser(); var result = parser.ParseLesson(lesson); return(result); }
public static void Main(string[] args) { var document = Lessons.LessonLoader.LoadSampleLesson(); var parser = new LessonParser(); var lesson = parser.ParseLesson(document); var lessonStr = lesson.ToString(); }
public void GettingLessonsIntegrationTest() { var provider = new PlanProvider(TestPlanUrl); var lessonForClass = LessonParser.GetLessonsForClass(provider, "24") .Where(l => l.DayOfWeek == 1 && l.Number == 6).First(); var lessonForTeacher = LessonParser.GetLessonsForTeacher(provider, "14") .Where(l => l.DayOfWeek == 1 && l.Number == 6).First(); var lessonForRoom = LessonParser.GetLessonsForRoom(provider, "41") .Where(l => l.DayOfWeek == 1 && l.Number == 6).First(); Assert.Equal(lessonForClass, lessonForTeacher); Assert.Equal(lessonForClass, lessonForRoom); Assert.Equal(lessonForTeacher, lessonForRoom); }
public void GettingLessonsForRoomTest() { var provider = new PlanProvider(TestPlanUrl); var expectedLesson = new Lesson() { Number = 3, Period = new Period() { Start = "09:50:00", End = "10:35:00" }, DayOfWeek = 1, Name = "zaj. wych.", ClassId = "24", TeacherId = "13", RoomId = "49" }; var actualLesson = LessonParser.GetLessonsForRoom(provider, "49") .Where(l => l.DayOfWeek == 1 && l.Number == 3).First(); Assert.Equal(expectedLesson, actualLesson); }
public ActionResult ForRoom([FromQuery][Required] string planUrl, [FromQuery][Required] string roomId) { if (String.IsNullOrWhiteSpace(planUrl) || String.IsNullOrWhiteSpace(roomId)) { return(BadRequest()); } else { try { var provider = new PlanProvider(planUrl); return(Ok(LessonParser.GetLessonsForRoom(provider, roomId))); } catch (WebException e) { return(StatusCode(406, $"Error during plan download: '{e.Message}'")); } catch (UriFormatException e) { return(StatusCode(406, $"Error during parsing url: '{e.Message}'")); } } }