public override List <Group> ParseEntitiesFromCode(string htmlCode) { var groups = new List <Group>(); var regex = new Regex(Pattern); var matcher = regex.Matches(htmlCode); for (int i = 0; i < matcher.Count; i++) { int id; if (int.TryParse(matcher[i].Groups[1].ToString(), out id)) { string name = matcher[i].Groups[2].ToString(); Degree.Degrees degree = Degree.GetDegreeForGroupNamed(name); TeachingForm.TeachingForms form = TeachingForm.GetTeachingFormForGroupNamed(name); groups.Add(new Group(id, name, degree, form)); } else { groups.Add(new Group(-1, "ABC", Degree.Degrees.Postgraduation, TeachingForm.TeachingForms.ExtramuralAbbreviated)); } //throw new Exception("Не удалось распознать ID группы"); } return(groups); }
private void AddTeachingForm(string shortName, string name, string description, int capacity) { var form = Db.TeachingForms.SingleOrDefault(x => x.ShortName.Equals(shortName)); if (form == null) { form = new TeachingForm { Name = name, ShortName = shortName, Description = description, Capacity = capacity }; Db.TeachingForms.Add(form); } else { form.Name = name; form.Description = description; form.Capacity = capacity; } Db.SaveChanges(); }
protected void Page_Load(object sender, EventArgs e) { string serializedString = JSONParser.Instance.Serialize(TeachingForm.GetTeachingFormsList()); Response.Write(serializedString); }