Ejemplo n.º 1
0
        public String UpdateStudentApply(String tg_id, String s_id, int accept)
        {
            getRoleInfo();
            int max_student     = teacherHelper.GetMaxStudentNum(tid, s_id);     //取得老師可指導學生上限
            int current_student = teacherHelper.GetCurrentStudentNum(tid, s_id); //取得目前學生

            if (current_student >= max_student & accept == 1)
            {
                return("100");
            }
            JObject update_apply = teacherHelper.UpdateApply(tg_id, accept);

            if (accept == 1)
            {
                if (teacherHelper.CheckAllApply(tg_id) == 0)
                {
                    //add new pair
                    teacherHelper.AddApplyPair(tg_id, s_id);
                    //update student apply history
                    teacherHelper.UpdateStudentApplyHistory(tg_id, state: 1); //state=1 means success
                                                                              //update student apply status
                    teacherHelper.UpdateStudentApplyStatus(s_id, state: 0);
                }
            }
            else if (accept == 2)
            {
                teacherHelper.UpdateStudentApplyHistory(tg_id, 2); //state=2 means reject
                //update student apply status
                teacherHelper.UpdateStudentApplyStatus(s_id, 0);
            }

            return(update_apply["status"].ToString(Formatting.None));
        }
Ejemplo n.º 2
0
        public String UpdateStudentApply(String tg_id, String s_id, int accept)
        {
            tid = User.Identity.GetUserId();
            TeacherHelper teacherHelper = new TeacherHelper();
            JObject       update_apply  = teacherHelper.UpdateApply(tid, tg_id, accept);

            //check if all teacher agree for application,
            /* CheckAllApply get 0 means all student apply in accept */
            if (teacherHelper.CheckAllApply(tg_id) == 0)
            {
                //add new pair
                teacherHelper.AddApplyPair(tg_id, s_id);
                //update student apply history
                teacherHelper.UpdateStudentApplyHistory(tg_id, state: 1); //state=1 means success
            }
            else
            {
                //全部都完成了,而且有老師拒絕
                //check if all teacher are check and there's rejection to apply
                //todo - update history student apply (state and ...?)
                //remove -
            }

            return(update_apply["status"].ToString(Formatting.None));
            //if ((bool)change["status"])
            //    return change["status"].ToString(Formatting.None);
            //else
            //    return change["msg"].ToString();
        }