public void viewUpdated(EModelUpdateType updateType)
        {
            //Get data from model
            ModelUser student = this.model.getItem <ModelUser>(DataKeys.getUserKey(studentId));

            //change data into list of AssignmentViewCellData

            Collection <StudentAssignmentViewCellData> assignments = new Collection <StudentAssignmentViewCellData>();

            Collection <AssignmentListItem> listItems = student.makeStudentAssignmentListItems();

            foreach (AssignmentListItem assignment in listItems)
            {
                int dueDateResult = DateTime.Compare(assignment.dueDate, DateTime.Now);


                if (!(dueDateResult <= 0 && assignment.isDone == true))
                {
                    StudentAssignmentViewCellData viewCell = new StudentAssignmentViewCellData(
                        assignment,
                        this
                        );

                    assignments.Add(viewCell);
                }
            }

            //set datacells as item source for list
            this.assignmentListView.ItemsSource = assignments;
        }
예제 #2
0
        public void register(IHomeWorkModel model, int studentId)
        {
            this.model     = model;
            this.studentId = studentId;


            model.addWatcher(viewUpdated, DataKeys.getUserKey(studentId));
        }
예제 #3
0
        public async Task <string> execute()
        {
            Response response = await this.model.editAssignment(
                this.assignmentName,
                this.assignmentDueDate,
                this.assignmentDescription,
                this.isClosed,
                this.assignmentId,
                this.teacherId

                );

            if (!response.isOk)
            {
                return(response.message);
            }

            ModelUser teacher = this.model.getItem <ModelUser>(DataKeys.getUserKey(this.teacherId));

            ModelAssignment assignment = null;

            foreach (ModelAssignment ass in teacher.assignments)
            {
                if (ass.id == this.assignmentId)
                {
                    assignment = ass;
                }
            }

            if (assignment == null)
            {
                return("Failure, assignment not on model");
            }

            AssignmentFetchObject aFO = new AssignmentFetchObject(this.assignmentId,
                                                                  assignment.classRoomName,
                                                                  this.assignmentDueDate,
                                                                  this.assignmentDescription,
                                                                  this.isClosed,
                                                                  this.assignmentName
                                                                  );

            ServerResponse serverResponse = await this.model.fetchDataBaseObject(aFO, ECmdObjType.assignmentFetchObj);

            if (!serverResponse.errorResponse.isOk)
            {
                return(serverResponse.errorResponse.message);
            }

            if (aFO.isSame(serverResponse.fetchObject))
            {
                return("Success! \n" + aFO.render());
            }
            else
            {
                return("Failure :(");
            }
        }
예제 #4
0
        public ClassRoomPage(string classRoomName, int teacherId)
        {
            this.classRoomName = classRoomName;

            this.model = ((App)Application.Current).model;
            this.model.initializeForClassRoom(classRoomName);

            InitializeComponent();

            this.classRoomName_Label.Text = classRoomName;

            ModelUser user = this.model.getItem <ModelUser>(DataKeys.getUserKey(teacherId));

            this.assignmentListView.register(model, user, classRoomName);

            ClassRoomPageControler controler = new ClassRoomPageControler(this, addAssignment_button, teacherId, classRoomName, assignmentListView, user);
        }
예제 #5
0
        public void viewUpdated(EModelUpdateType updateType)
        {
            //Get data from model
            ModelUser student = model.getItem <ModelUser>(DataKeys.getUserKey(studentId));

            //change data into list of classRoomViewCellData

            Collection <SubscriptionViewCellData> subscriptions = new Collection <SubscriptionViewCellData>();

            Collection <Students_SubscriptionListItem> subscriptionsListItems = student.makeSubscriptionListItems();

            foreach (Students_SubscriptionListItem subscription in subscriptionsListItems)
            {
                SubscriptionViewCellData viewCell = new SubscriptionViewCellData(subscription.name, subscription.nextDue);

                subscriptions.Add(viewCell);
            }

            //set datacells as item source for list
            this.subscriptionsListView.ItemsSource = subscriptions;
        }
예제 #6
0
 private string getUserDataKey()
 {
     return(DataKeys.getUserKey(userId));
 }
 private string getUserDataKey()
 {
     return(DataKeys.getUserKey(this.user.id));
 }
예제 #8
0
 private string getTeacherDataKey()
 {
     return(DataKeys.getUserKey(this.teacherId));
 }