async Task ExecuteLoadItemsCommand() { IsBusy = true; try { Courses.Clear(); var items = await CourseDataStore.GetItemsAsync(true); if (!string.IsNullOrWhiteSpace(SearchPararmeter)) { items = items.Where(c => c.Name.ToLower().Contains(SearchPararmeter.ToLower())); } foreach (var item in items) { Courses.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public SubjectDetailsViewModel(string id, MainWindowViewModel mainWindowViewModel) { _mainWindowViewModel = mainWindowViewModel; _adding = false; Subject = SubjectDao.FindById(id); var softwareList = SoftwareDao.FindAll(); foreach (var software in softwareList) { var softwareViewModel = new SoftwareViewModel(software) { IsChecked = Subject.RequiredSoftware.FirstOrDefault(s => s.Id == software.Id) != null }; SoftwareList.Add(softwareViewModel); } var courses = CourseDao.FindAll(); courses.ForEach(c => Courses.Add(c)); foreach (var subject in SubjectDao.FindAll()) { _takenIds.Add(subject.Id); } }
private void AddCourses(Patient patient) { foreach (Course c in patient.Courses) { Courses.Add(c.Id); } }
/// <summary> /// 加载课程信息 /// </summary> /// <returns></returns> private async Task LoadCourses() { Courses.Clear(); JObject json = await NetHelper.Send(new { Command = Admin_Courses }); if (!json[OK].Value <bool>()) { TaskDialog.ShowError("加载课程列表失败:" + json[Message].Value <string>()); return; } JArray array = json[Data] as JArray; foreach (dynamic item in array) { UICourse course = new UICourse(); course.Id = item.Id; course.Name = item.Name; course.Teacher = item.Teacher; course.TeacherId = item.TeacherId; course.Year = item.Year; course.Term = item.Term; Courses.Add(course); } }
public void AddCourse(TTCourse ttc) { Courses.Add(new Course(ttc.ID, ttc.CatalogNumber, Utils.UnescapeUnicode(ttc.Name), ttc.AcademicYear)); }
async Task LoadTerm() { IsBusy = true; try { Term = await SqliteConn.Table <Term>().FirstOrDefaultAsync(t => t.Id == Term.Id); Title = $"{Term.Title}'s courses"; var courses = await SqliteConn.Table <Course>().Where(c => c.TermId == Term.Id).OrderBy(term => term.Start).ToListAsync(); // Loading the data causes the refresh to trigger lock (coursesLock) { CanAddCourse = courses.Count < 6; Courses.Clear(); foreach (var course in courses) { Courses.Add(course); } } } catch (Exception ex) { Debug.Write(ex); } finally { IsBusy = false; } }
public void ImportInfo(Student student) { if (!Courses.Contains(student.CourseId)) { Courses.Add(student.CourseId); } }
public IActionResult Courses(Course model) { List <Course> Courses; using (var sr = new StreamReader(@"./Data/courses.json")) { string json = sr.ReadToEnd(); Courses = JsonSerializer.Deserialize <List <Course> >(json); } if (ModelState.IsValid) { Courses.Add(model); using (var sr = new StreamWriter(@"./Data/courses.json")) { string serialized = JsonSerializer.Serialize(Courses); sr.Write(serialized); } return(RedirectToAction("Courses")); } ViewData["Courses"] = Courses; return(View()); }
public void UpdatePatient() { var esapi = ESAPIApplication.Instance.Context; var sc = ESAPIApplication.Instance.ScriptContext; var patients = esapi.PatientSummaries.ToList(); var found = esapi.PatientSummaries.FirstOrDefault(p => p.Id == PatientId); if (found != null) { var patient = esapi.OpenPatientById(PatientId); typeof(V.ScriptContext) .GetField("m_patient", BindingFlags.Instance | BindingFlags.NonPublic) .SetValue(sc, patient); UpdateStatus(string.Format("Current Context is {0}, {1} | {2}", found.LastName, found.FirstName, found.Id)); Courses.Clear(); var courses = patient.Courses; courses.ToList().ForEach(c => Courses.Add(c)); SelectedCourse = Courses.FirstOrDefault(); OnPropertyChanged("Courses"); OnPropertyChanged("SelectedCourse"); OnPropertyChanged("Status"); } else { MessageBox.Show(string.Format("Can't find patient {0}.", PatientId), "ERROR"); UpdateStatus(""); } }
public void MakeCourse() { Course newCour = new Course(); Courses.Add(newCour); Console.WriteLine("Enter course's title: "); newCour.Title = Console.ReadLine(); if (newCour.Title.Length < 1) { Console.WriteLine("Title was left empty"); Console.WriteLine("Will put synthetic data"); newCour.Title = "HTML"; } Console.WriteLine("Enter course's stream: "); newCour.Stream = Console.ReadLine(); if (newCour.Stream.Length < 1) { Console.WriteLine("Stream was left empty"); Console.WriteLine("Will put synthetic data"); newCour.Stream = "Web Development"; } Console.WriteLine("Enter course's type: "); newCour.Type = Console.ReadLine(); if (newCour.Type.Length < 1) { Console.WriteLine("Type was left empty"); Console.WriteLine("Will put synthetic data"); newCour.Type = "Practical Subject"; } try { Console.WriteLine("Enter course's start date: "); newCour.StartDate = Convert.ToDateTime(Console.ReadLine()); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); Console.WriteLine("Will put synthetic data"); newCour.StartDate = new DateTime(2020, 5, 10); } try { Console.WriteLine("Enter course's end date: "); newCour.EndDate = Convert.ToDateTime(Console.ReadLine()); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); Console.WriteLine("Will put synthetic data"); newCour.EndDate = new DateTime(2020, 11, 22); } }
/// <summary> /// Enrolls the in course. /// </summary> /// <param name="courseToEnrollInto">The course to enroll into.</param> public void EnrollInCourse(Course courseToEnrollInto) { if (courseToEnrollInto != null)//&& !courses.Contains(courseToEnrollInto) { Courses.Add(courseToEnrollInto); } }
//Create all courses from data private void CreateCourses(IOFstandard.Course[] courses) { foreach (var course in courses) { Course crs = new Course { Name = course.Name, }; Courses.Add(crs); int i = 0; foreach (var courseControl in course.CourseControl) { Control control = Controls.FirstOrDefault(c => c.Code == courseControl.Control.FirstOrDefault()); if (control != null) { CourseControl cc = new CourseControl { Control = control, Course = crs, Order = i, Type = courseControl.type.ToString() }; CourseControls.Add(cc); i++; } } } }
private void AddCourse(Course course) { Courses.Add(course); using (con = new SQLiteConnection(connectionString)) { con.Open(); try { using (SQLiteCommand insertSQL = con.CreateCommand()) { insertSQL.CommandText = "INSERT INTO Kursy(IdKursu, NazwaKursu) VALUES (@id,@name)"; insertSQL.Parameters.Add(new SQLiteParameter("@id", SqlDbType.Int) { Value = course.Id }); insertSQL.Parameters.AddWithValue("@name", course.Name); insertSQL.ExecuteNonQuery(); } con.Close(); } catch (Exception ex) { MessageBox.Show("Błąd połączenia z bazą: " + ex); } } }
/// <summary> /// Новый курс /// </summary> /// <param name="newCourse"></param> public void AddCourse(Course newCourse) { if (newCourse == null) { return; } Courses.Add(newCourse); }
public void AddCourse(string title, StreamType stream, CourseType type, DateTime startDate, Random random) { int id = GetRandomUniqueCourseId(random); var course = new Course(id, title, stream, type, startDate); Courses.Add(course); Console.WriteLine($"Created course {course}"); }
public void AddCourse(Course course) { if (Cathedra.CheckCourseExistance(course)) { course.Students.Add(this); Courses.Add(course); } }
public void NewJSONTopic(string title, string duration) { Courses.Add(new Course() { title = title, duration = duration }); }
private void LoadCourses() { Courses.Clear(); foreach (var course in db.GetCourses()) { Courses.Add(course); } }
public void AddCource(string title, string stream, string type, DateTime start_date, DateTime end_date) { int current_id = Courses.Count + 1; var course = new Course(current_id, title, stream, type, start_date, end_date); Courses.Add(course); PrivateSchool.OutputCourses(course); }
public void EnrollCourse(Course course) { if (Courses.Contains(course)) { throw new InvalidOperationException("Student is already enrolled in this course"); } Courses.Add(course); }
public void RegisterCourse(Course course) { if (course == null) { throw new ArgumentNullException(); } Courses.Add(course); }
//Gets each row in the selected course tables on the webpage //Does not attempt to parse all aspects of the table, this method simply gets each row. public void LoadCourseRows() { string xPath = "//div[@id='{0}']//table"; if (!this.tableClass.Equals(string.Empty)) { xPath += "[contains(@class, '{1}')]"; } List <HtmlNode> found = Document.query(String.Format(xPath, this.parentID, this.tableClass)); int tableIndex = 0; //Each table found from the supplied xpath. foreach (HtmlNode table in found) { if (table.HasClass("sc_footnotes")) { break; } //Query for table rows AFTER querying for the table itself //This ensures each separation of table rows when many tables are present List <HtmlNode> rows = Document.query(table.XPath + @"//tr"); //Initialize the next list of courses before iterating over the courses. Courses.Add(new List <Entry>()); //Each childnode foreach (HtmlNode row in rows) { //If this is a hidden, header, or empty then skip it outright. if (row.HasClass("hidden") || row.ParentNode.Name == "thead" || row.InnerText.Trim().Length == 0) { continue; } else if (row.HasClass("plangridyear")) { Courses[tableIndex].Add(new Year(row)); } else if (row.HasClass("plangridterm")) { Courses[tableIndex].Add(new Term(row)); } else if (row.HasClass("plangridsum")) { Courses[tableIndex].Add(new SumCredits(row)); } else if (row.HasClass("plangridtotal") || row.HasClass("listsum")) { Courses[tableIndex].Add(new TotalCredits(row)); } else { Courses[tableIndex].Add(new Course(row)); } } //Move onto the next table tableIndex++; } }
private void SetCourses() { SelectedCourse = null; Courses.Clear(); foreach (var course in _patient.Courses) { Courses.Add(course); } }
public HttpResponseMessage Post([FromBody] Course c) { c.Id = Courses.Count; Courses.Add(c); var msg = Request.CreateResponse(HttpStatusCode.Created); msg.Headers.Location = new Uri(Request.RequestUri + c.Id.ToString()); return(msg); }
public void AddCourse(int courseId, string courseName) { lock (Courses) { ValidateId(courseId); ValidateName(courseName); Course course = new Course(courseId, courseName); Courses.Add(course); } }
public TeacherDTO(Teacher teacher) : base(teacher) { if (teacher != null) { foreach (Course course in teacher.Courses) { Courses.Add(new CourseListDTO(course)); } } }
public CourseList() : base("courses.bin") { this.Courses = new Dictionary <string, Course>(); var data = this.LoadFromStorage <KeyValuePair <string, Course> >(); foreach (var item in data) { Courses.Add(item.Key, item.Value); } }
private async Task AddCourses() { var viewModel = new CoursesDetailViewModel(new CoursesTableViewModel(), _coursesStore, _pageService); viewModel.CourseAdded += (source, course) => { Courses.Add(new CoursesTableViewModel(course)); }; await _pageService.PushModalAsync(new CoursesDetailPage(viewModel)); }
public bool AddMenuCourse(string name) { var course = new Course(this, name); if (Courses.Any(l => l.Id == course.Id)) { return(false); } Courses.Add(course); return(true); }
public void Fetch(string filepath1, string filepath2, string filepath3) { FetchStudent(filepath1); FetchCourse(filepath2); FetchStudentCourse(filepath3); foreach (string line in StudentList) { if (line == StudentList[0]) { continue; } else { string[] properties = line.Split(','); Students.Add(new Student { StudentID = Int32.Parse(properties[0]), StudentName = properties[1], StudentAddress = properties[2], PhoneNumber = properties[3] }); } } foreach (string line in CourseList) { if (line == CourseList[0]) { continue; } else { string[] properties = line.Split(','); Courses.Add(new Course { CourseID = Int32.Parse(properties[0]), CourseName = properties[1] }); } } foreach (string line in StudentCourseList) { if (line == StudentCourseList[0]) { continue; } else { string[] properties = line.Split(','); StudentCourses.Add(new StudentCourse { id = Int32.Parse(properties[0]), StudentID = Int32.Parse(properties[1]), CourseID = Int32.Parse(properties[2]) }); } } }
//======================================method to add teacher========================================== public static void AddTeacher() { string name; string phone; string email; Courses approvedCourses = new Courses(); long check; Console.Write("Enter Name\n"); name = Console.ReadLine(); Console.Write("Enter 10 digit Phone number\n"); string input = Console.ReadLine(); try { check = Convert.ToInt64(input); } catch { Console.WriteLine("Phone number must be 10 numerical digits"); return; } if (input.ToString().Length != 10) { Console.WriteLine("Phone number entered is not 10 digits, please try again"); return; } else { phone = input; } Console.Write("Enter Email address\n"); email = Console.ReadLine(); //display all course options if (name == "" || email == "") { Console.WriteLine("One or more fields left empty, please try again"); return; } foreach (Cours c in dm.DBCourses) { Console.WriteLine("Course ID: {0}\tName: {1}", c.CourseID, c.CourseName); } //bool and while loop to keep adding courses until the user stops bool keepAdding = true; //loops through all courses comparing entered ID to courseIDs. If a match is found, bool is set to true and if statement is entered, assigning match //to the list. After this is completed, ask user if they want to add more classes and loop again. while (keepAdding) { Console.WriteLine("Enter ID of a course this teacher can teach"); //setting up tryparse for error checking string answer = Console.ReadLine(); int id; bool result = int.TryParse(answer, out id); bool match = false; Cours matchedCourse = null; foreach (Cours c in dm.DBCourses) { if (id == c.CourseID) { match = true; matchedCourse = c; } } if (match == true) { //nested if statement checks for duplicates and writes and error message if found. if (approvedCourses.Contains(matchedCourse)) { Console.WriteLine("this course has already been added, you can't add it twice!"); } else { approvedCourses.Add(matchedCourse); Console.WriteLine("class successfully added"); } } else { Console.WriteLine("invalid class number entered"); return; } Console.WriteLine("Can this teacher teach another course?\n1...Yes\n2...No"); string anotherClass = Console.ReadLine(); switch (anotherClass) { case "1": break; case "2": keepAdding = false; break; } } //once all classes are assigned, check for null, then create teacher with those classes //and add him/her to list if (approvedCourses.CourseCollection.Count != 0) { //create empty list of classes to be used when scheduling a class List<classItem> classesWith = new List<classItem>(); //set bool value to true on all teachers bool isTeacher = true; Teacher t = new Teacher(name, phone, email, isTeacher, classesWith, approvedCourses); if (people.Contains(t)) { Console.WriteLine("The name, phone number, or email entered is already taken, please enter a new one"); return; } else { people.Add(t); //bool used in scheduling a class for error checking hasTeacher = true; Console.WriteLine("{0} added Successfully!", t.Name); } } else { Console.WriteLine("No courses were successfully added that this teacher can teach. Teacher was not added."); } }