public CreateExamViewModel() { try { Response <List <QualificationModel> > response = qualificationManager.GetAllQualifications(); List <QualificationModel> data = response.Data; foreach (var qualif in data) { QualifsList.Add(qualif.Code); } Response <List <ClassSimpleModel> > responseClass = userManager.GetAllClasses(); List <ClassSimpleModel> dataClass = responseClass.Data; foreach (var className in dataClass) { ClassesList.Add(className.ClassName); } } catch (Exception exception) { NotifyMessageViewVisibility.ShowMessageView("Błąd!", exception.Message); } }
//Get data private void GetData() { try { var doc = new HtmlDocument(); URL = ConfigurationManager.AppSettings["BaseURL"] + this.ClubID; doc.LoadHtml(ReadData(URL)); var table = doc.GetElementbyId("tblSchedule"); foreach (var tr in table.SelectSingleNode("tbody").SelectNodes("tr")) { string time = tr.SelectSingleNode("th").SelectSingleNode("h5").InnerText; string className = string.Empty; string classDescriptionuri = string.Empty; string classDescription = string.Empty; int currDayInt = 0; foreach (var td in tr.SelectNodes("td")) { string currDay = Days[currDayInt]; if (td.HasChildNodes) { className = td.InnerText; classDescription = className.Split('(')[0].Trim(); try { classDescriptionuri = td.SelectSingleNode(".//strong//a").GetAttributeValue("href", "Class Description Link not found"); } catch (NullReferenceException) { classDescriptionuri = td.SelectSingleNode(".//a").GetAttributeValue("href", "Class Description Link not found"); } if (!ClassDescriptionsURIs.Contains(classDescriptionuri)) { ClassDescriptionsURIs.Add(classDescriptionuri); } } else { className = "No Class"; classDescriptionuri = "No Description URI"; } ClassesList.Add(new Class(time, currDay, className, classDescriptionuri, classDescription)); currDayInt += 1; } //Store unique times if (!Times.Contains(time)) { Times.Add(time); } } } catch (Exception e) { throw new Exception(e.Message); } }
public void AddClass(Class c) { if (ClassById.ContainsKey(c.ID)) { throw new InvalidOperationException(String.Format("Class with ID={0} already exists", c.ID)); } if (ClassByCompactId.ContainsKey(c.CompactID)) { throw new InvalidOperationException(String.Format("Class with CompactID={0} already exists", c.ID)); } ClassById[c.ID] = c; ClassByCompactId[c.CompactID] = c; ClassesList.Add(c); c.Schema = this; }