Example #1
0
        //fills the model with the values to be displayed by the view
        void FillModel(ClassList list, ClassRequests requests)
        {
            //clears the lists so they doesnt just append the new values on when refreshing
            this.Model.List.Clear();
            this.Model.Requests.Clear();

            int counter = 0;

            //adds the classes to the class list in the Model
            foreach (int classID in list.classIDs)
            {
                this.Model.List.Add(new Classes()
                {
                    classID = classID, memberCount = list.memberCounts[counter]
                });
                counter += 1;
            }

            //reset counter
            counter = 0;

            //adds the class requests to the class requests in the Model
            foreach (string classID in requests.classIDs)
            {
                this.Model.Requests.Add(new Request()
                {
                    classID = classID, username = requests.usernames[counter], pointer = counter
                });
                counter += 1;
            }
        }
Example #2
0
        //gets the list of classes and class joining requests
        void RefreshList()
        {
            //gets the class list
            ServerConnection server = new ServerConnection();
            string           JSON   = server.ServerRequest("CLASSLIST", new string[] { this.username });

            //clears the current class list
            this.Model.List.Clear();
            ClassList list = new ClassList();

            list = JsonConvert.DeserializeObject <ClassList>(JSON);

            //gets the class requests
            ServerConnection server2 = new ServerConnection();

            JSON = server.ServerRequest("REQUESTLIST", new string[] { this.username });
            //clears the current class list
            this.Model.List.Clear();
            ClassRequests requests = new ClassRequests();

            requests = JsonConvert.DeserializeObject <ClassRequests>(JSON);
            FillModel(list, requests);
        }