コード例 #1
0
        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;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        //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
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        //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;
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        /**
         * 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
        }
コード例 #9
0
        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
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        //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;
        }
コード例 #13
0
        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);
            }
        }
コード例 #14
0
        public bool createStudent(Student student, string password)
        {
            // Create the user
            Dictionary <String, String> postData = new Dictionary <string, string>();

            postData.Add("username", student.Username);
            postData.Add("password", password);
            postData.Add("fname", student.FirstName);
            postData.Add("lname", student.LastName);
            postData.Add("email", student.Email);
            postData.Add("role", "STUDENT");
            String json = APIProxy.PostToAPI(String.Format("{0}?team=general&function=createUser", API_URL), postData).Result;

            int userID = extractIDFromJson(json);

            if (json == null || userID == -1)
            {
                return(false);
            }

            // Create the student
            postData = new Dictionary <string, string>();
            postData.Add("userID", Convert.ToString(userID));
            postData.Add("yearLevel", Convert.ToString(student.YearLevel));
            postData.Add("gpa", Convert.ToString(student.GPA));
            json = APIProxy.PostToAPI(String.Format("{0}?team=general&function=postStudent", API_URL), postData).Result;

            int studentID = extractIDFromJson(json);

            if (json == null || studentID == -1)
            {
                this.deleteUser(userID);
                return(false);
            }
            return(true);
        }