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 void toggleSection(int ID) { Dictionary <String, String> postData = new Dictionary <string, string>(); postData.Add("sectionID", Convert.ToString(ID)); String json = APIProxy.PostToAPI(String.Format("{0}?team=student_enrollment&function=toggleSection", API_URL), postData).Result; }
//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 void toggleCourse(int ID) // Make sure this is what is supposed to be in the API { Dictionary <String, String> postData = new Dictionary <string, string>(); postData.Add("courseID", Convert.ToString(ID)); String json = APIProxy.PostToAPI(String.Format("{0}?team=student_enrollment&function=toggleCourse", API_URL), postData).Result; }
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); }
public void withdrawWaitlistStudent(Student student, Section section) { Dictionary <String, String> postData = new Dictionary <string, string>(); postData.Add("studentID", Convert.ToString(student.ID)); postData.Add("sectionID", Convert.ToString(section.ID)); String json = APIProxy.PostToAPI(String.Format("{0}?team=student_enrollment&function=withdrawFromWaitlist", API_URL), postData).Result; }
//Methods for interactions between models public void enrollStudent(Student student, Section section) { Dictionary <String, String> postData = new Dictionary <string, string>(); postData.Add("studentID", Convert.ToString(student.ID)); postData.Add("sectionID", Convert.ToString(section.ID)); String json = APIProxy.PostToAPI(String.Format("{0}?team=student_enrollment&function=enrollStudent", API_URL), postData).Result; // TODO: See what comes back from JSON }
public User login(string username, string password) { Dictionary <String, String> postData = new Dictionary <string, string>(); postData.Add("username", username); postData.Add("password", password); String json = APIProxy.PostToAPI(String.Format("{0}?team=general&function=login", API_URL), postData).Result; User user = (User)ModelFactory.createModelFromJson("user", json); return(user); }
//Methods for updating entities within the API /** * If goal is to update the availability, use the toggleCourse method. */ public void updateCourse(Course course) { Dictionary <String, String> postData = new Dictionary <string, string>(); postData.Add("courseCode", course.CourseCode); postData.Add("courseName", course.Name); postData.Add("credits", Convert.ToString(course.Credits)); postData.Add("minGPA", Convert.ToString(course.MinGPA)); postData.Add("id", Convert.ToString(course.ID)); String json = APIProxy.PostToAPI(String.Format("{0}?team=student_enrollment&function=updateCourse", API_URL), postData).Result; }
//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 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[] 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 bool deleteCourse(int courseID) { Dictionary <String, String> postData = new Dictionary <string, string>(); postData.Add("id", Convert.ToString(courseID)); String json = APIProxy.PostToAPI(String.Format("{0}?team=general&function=deleteCourse", API_URL), postData).Result; if (json != null && json == "Success") { return(true); } return(false); }
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()); }
/** * If goal is to update the availability, use the toggleSection method. */ public void updateSection(Section section) { Dictionary <String, String> postData = new Dictionary <string, string>(); postData.Add("id", Convert.ToString(section.ID)); postData.Add("courseID", Convert.ToString(section.CourseID)); postData.Add("professorID", Convert.ToString(section.InstructorID)); postData.Add("maxStudents", Convert.ToString(section.MaxStudents)); postData.Add("termID", Convert.ToString(section.TermID)); postData.Add("classroomID", Convert.ToString(section.LocationID)); String json = APIProxy.PostToAPI(String.Format("{0}?team=student_enrollment&function=updateSection", API_URL), postData).Result; // TODO: See what comes back from JSON }
public void createTerm(Term term) { Dictionary <String, String> postData = new Dictionary <string, string>(); postData.Add("termCode", term.Code); string start = (term.StartDate).ToString("yyyy-MM-dd") + " 00:00:00.000"; string end = (term.EndDate).ToString("yyyy-MM-dd") + " 00:00:00.000"; postData.Add("startDate", start); postData.Add("endDate", end); String json = APIProxy.PostToAPI(String.Format("{0}?team=student_enrollment&function=postTerm", API_URL), postData).Result; // TODO: See what comes back from JSON }
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 int createCourse(Course course) { Dictionary <String, String> postData = new Dictionary <string, string>(); postData.Add("courseCode", course.CourseCode); postData.Add("courseName", course.Name); postData.Add("credits", Convert.ToString(course.Credits)); postData.Add("minGPA", Convert.ToString(course.MinGPA)); String json = APIProxy.PostToAPI(String.Format("{0}?team=general&function=postCourse", API_URL), postData).Result; int id = parseID(json); return(id); }
public int createSection(Section section) { Dictionary <String, String> postData = new Dictionary <string, string>(); postData.Add("courseID", Convert.ToString(section.CourseID)); postData.Add("professorID", Convert.ToString(section.InstructorID)); postData.Add("maxStudents", Convert.ToString(section.MaxStudents)); postData.Add("termID", Convert.ToString(section.TermID)); postData.Add("classroomID", Convert.ToString(section.LocationID)); String json = APIProxy.PostToAPI(String.Format("{0}?team=student_enrollment&function=postSection", API_URL), postData).Result; int id = extractIDFromJson(json); return(id); }
//Methods for adding data to the database public void createBook(Book book, String authorFirstName, String authorLastName, String publisher) { Dictionary <String, String> postData = new Dictionary <string, string>(); postData.Add("publisher_name", publisher); postData.Add("isbn", Convert.ToString(book.ISBN)); postData.Add("f_name", authorFirstName); postData.Add("l_name", authorLastName); postData.Add("title", book.Title); postData.Add("price", Convert.ToString(book.Price)); postData.Add("thumbnail_url", book.ThumbnailURL); postData.Add("available", book.Availability ? "true" : "false"); postData.Add("count", Convert.ToString(book.Count)); String json = APIProxy.PostToAPI(String.Format("{0}?team=book_store&function=createBook", API_URL), postData).Result; }
public void withdrawStudent(Student student, Section section) { Dictionary <String, String> postData = new Dictionary <string, string>(); postData.Add("studentID", Convert.ToString(student.ID)); postData.Add("sectionID", Convert.ToString(section.ID)); String json = APIProxy.PostToAPI(String.Format("{0}?team=student_enrollment&function=withdrawStudent", API_URL), postData).Result; // See what comes back from the API //If the section has a waitlist, add a student to the classlist Student[] waitlistStudents = getSectionWaitlist(section); if (waitlistStudents.Length > 0) { //Add first student enrollStudent(waitlistStudents[0], section); } }