private IList <Auditorium> ParseAuditoriums(JsonElement json) { this.logger.LogDebug("ParseAuditoriums"); var tempList = new List <Auditorium>(); foreach (var auditorium in json.EnumerateArray()) { if (!auditorium.TryGetProperty(AuditoriumTitleKey, out var titleElement)) { continue; } var name = titleElement.GetString().Trim(); //name = Auditorium.parseEmoji(name) var color = auditorium.TryGetProperty(AuditoriumColorKey, out var colorElement) ? colorElement.GetString() : string.Empty; tempList.Add(new Auditorium( AuditoriumExt.ReplaceEmojiByText(name), color )); } return(tempList); }
private Lesson ParseLesson(HtmlNode node, int order, Teacher teacher) { var emoji = node.Elements("b") .Select(it => AuditoriumExt.ReplaceEmojiByText(it.InnerText)) .FirstOrDefault() ?? string.Empty; var auditoriums = node.Descendants() .Where(it => it.HasClass("lesson__auditory")) .Select(it => new Auditorium(emoji + " " + it.InnerText, string.Empty)); var(dateFrom, dateTo) = ParseDates(node); var lessonTitle = node.Descendants() .Where(it => it.HasClass("lesson__subject")) .FirstOrDefault()?.InnerText ?? ""; var match = regex0.Matches(lessonTitle).LastOrDefault(); var lessonType = match?.Groups?.Values.ElementAtOrDefault(1)?.Value ?? "Другое"; if (match != null) { lessonTitle = lessonTitle.Replace($"({lessonType})", ""); } lessonTitle = ProcessTitle(lessonTitle); lessonType = LessonExt.FixTeacherType(lessonType, lessonTitle); var groups = node.Descendants() .Where(it => it.HasClass("lesson__group")) .Select(it => new Group(it.InnerText, false)); return(new Lesson( order, lessonTitle, lessonType, new List <Teacher>() { teacher }, auditoriums.ToList(), groups.ToList(), dateFrom, dateTo )); }