//Methods for Retreiving data from API public Admin getAdmin(int ID) { String json = APIProxy.GetFromAPI(String.Format("{0}?team=general&function=getAdmin&adminID={1}", API_URL, ID)).Result; Admin admin = (Admin)ModelFactory.createModelFromJson("admin", json); return(admin); }
public Term[] getTerms() { String json = APIProxy.GetFromAPI(String.Format("{0}?team=student_enrollment&function=getTerms", API_URL)).Result; Term[] terms = (Term[])ModelFactory.createModelArrayFromJson("term", json); return(terms); }
public Book getBook(int ID) { String json = APIProxy.GetFromAPI(String.Format("{0}?team=book_store&function=getBook&bookID={1}", API_URL, ID)).Result; Book book = (Book)ModelFactory.createModelFromJson("book", json); return(book); }
public Student getStudent(int ID) { String json = APIProxy.GetFromAPI(String.Format("{0}?team=student_enrollment&function=getStudentUser&userID={1}", API_URL, ID)).Result; Student student = (Student)ModelFactory.createModelFromJson("student", json); return(student); }
public Term getTerm(String termCode) { String json = APIProxy.GetFromAPI(String.Format("{0}?team=student_enrollment&function=getTerm&termCode={1}", API_URL, termCode)).Result; Term term = (Term)ModelFactory.createModelFromJson("term", json); return(term); }
public Location getLocation(int ID) // TODO: Wait for a getRoom location in the API { String json = APIProxy.GetFromAPI(String.Format("{0}?team=facility_management&function=getClassroom&id={1}", API_URL, ID)).Result; Location location = (Location)ModelFactory.createModelFromJson("location", json); return(location); }
public User getUser(int ID) { String json = APIProxy.GetFromAPI(String.Format("{0}?team=general&function=getUser&userID={1}", API_URL, ID)).Result; User user = (User)ModelFactory.createModelFromJson("user", json); return(user); }
public Instructor getInstructor(int ID) { String json = APIProxy.GetFromAPI(String.Format("{0}?team=general&function=getUser&userID={1}", API_URL, ID)).Result; Instructor instructor = (Instructor)ModelFactory.createModelFromJson("instructor", json); return(instructor); }
public string getQuote() { string json = APIProxy.GetFromAPI("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1").Result; dynamic contents = JsonConvert.DeserializeObject(json); return(contents.First.content); }
public Course getCourse(int ID) { String json = APIProxy.GetFromAPI(String.Format("{0}?team=general&function=getCourse&courseID={1}", API_URL, ID)).Result; Course course = (Course)ModelFactory.createModelFromJson("course", json); return(course); }
public Section[] getCourseSections(Course course) { String json = APIProxy.GetFromAPI(String.Format("{0}?team=student_enrollment&function=getCourseSections&courseID={1}", API_URL, course.ID)).Result; Section[] sections = (Section[])ModelFactory.createModelArrayFromJson("section", json); return(sections); }
public Course[] getCourseList() { String json = APIProxy.GetFromAPI(String.Format("{0}?team=student_enrollment&function=getCourseList", API_URL)).Result; Course[] courses = (Course[])ModelFactory.createModelArrayFromJson("course", json); return(courses); }
//Returning arrays of Model objects from tables of IDs public Student[] getSectionStudents(Section section) { String json = APIProxy.GetFromAPI(String.Format("{0}?team=student_enrollment&function=getSectionEnrolled§ionID={1}", API_URL, section.ID)).Result; String[] studentIDs = ModelFactory.createIDListFromJson("student", json); List <Student> students = new List <Student>(); foreach (String studentID in studentIDs) { students.Add(getStudent(Convert.ToInt32(studentID))); } return(students.ToArray()); }
public Term getCurrentTerm() { String json = APIProxy.GetFromAPI(String.Format("{0}?team=student_enrollment&function=getTerms", API_URL)).Result; List <Term> terms = ((Term[])ModelFactory.createModelArrayFromJson("term", json)).ToList(); DateTime currentDate = DateTime.Now; Term currentTerm = null; if (terms.Exists(x => x.StartDate <= currentDate && x.EndDate >= currentDate)) { currentTerm = terms.Find(x => x.StartDate <= currentDate && x.EndDate >= currentDate); } return(currentTerm); }
public Section[] getInstructorSectionsByID(int id) { String json = APIProxy.GetFromAPI(String.Format("{0}?team=student_enrollment&function=getProfessorSections&professorID={1}", API_URL, id)).Result; String[] ids = ModelFactory.createIDListFromJson("sectionInstructor", json); List <Section> sections = new List <Section>(); foreach (String str in ids) { sections.Add(this.getSection(Convert.ToInt32(str))); } return(sections.ToArray()); }
public Course[] getCoursePrereqs(Course course) { String json = APIProxy.GetFromAPI(String.Format("{0}?team=student_enrollment&function=getPrereqs&courseID={1}", API_URL, course.ID)).Result; String[] courseIDs = ModelFactory.createIDListFromJson("course", json); List <Course> courses = new List <Course>(); foreach (String courseID in courseIDs) { courses.Add(getCourse(Convert.ToInt32(courseID))); } return(courses.ToArray()); }
public Section[] getStudentWaitlists(Student student) { String json = APIProxy.GetFromAPI(String.Format("{0}?team=student_enrollment&function=getStudentWaitlist&studentID={1}", API_URL, student.ID)).Result; String[] ids = ModelFactory.createIDListFromJson("section", json); List <Section> sections = new List <Section>(); foreach (String str in ids) { sections.Add(this.getSection(Convert.ToInt32(str))); } return(sections.ToArray()); }