Exemplo 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));
        }