public String UpdateStudentApply(String tg_id, String t_id, String s_id, int accept) { getRoleInfo(); int max_student = adminHelper.GetMaxStudentNum(t_id, s_id); //取得老師可指導學生上限 int current_student = adminHelper.GetCurrentStudentNum(t_id, s_id); //取得目前學生 if (current_student >= max_student & accept == 1) { return("100"); } JObject update_apply = adminHelper.UpdateApply(tg_id, t_id, adminId, accept); if (accept == 1) { //檢查是否可以新增 //新增 if (adminHelper.CheckAllApply(tg_id) == 0) { String time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //add new pair adminHelper.AddApplyPair(tg_id, s_id); //update student apply history adminHelper.UpdateStudentApplyHistory(tg_id, 1, time); //state=1 means success //update student apply status adminHelper.UpdateStudentApplyStatus(s_id, 0); //新增學生上限 } } else if (accept == 2) { String time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //update student apply history adminHelper.UpdateStudentApplyHistory(tg_id, 2, time); //state=2 means reject //update student apply status adminHelper.UpdateStudentApplyStatus(s_id, 0); } //check if all teacher agree for application, /* CheckAllApply get 0 means all student apply in accept */ return(update_apply["status"].ToString(Formatting.None)); //if ((bool)change["status"]) // return change["status"].ToString(Formatting.None); //else // return change["msg"].ToString(); }