/// <summary> /// get teacher credit from teacher table /// </summary> /// <param name="teacherId"></param> /// <returns></returns> public JsonResult GetCreditByTeacherId(int teacherId) { CourseAssignManager aCourseAssignManager = new CourseAssignManager(); int creditToBeTaken = aCourseAssignManager.GetCreditByTeacherId(teacherId); return(Json(creditToBeTaken, JsonRequestBehavior.AllowGet)); }
/// <summary> /// check if teacherAssignedCredit is more than the credit is being taken /// </summary> /// <param name="teacherID"></param> /// <param name="currentCreditTaking"></param> /// <returns></returns> public JsonResult CheckTakenCreditOverFlowsRemainingCredit(int teacherID, int currentCreditTaking) { CourseAssignManager aCourseAssignManager = new CourseAssignManager(); int creditToBeTaken = aCourseAssignManager.GetCreditByTeacherId(teacherID); int totalAssignedCredit = aCourseAssignManager.GetAssignedCreditByTeacherId(teacherID); totalAssignedCredit = totalAssignedCredit + currentCreditTaking; if (totalAssignedCredit > creditToBeTaken) { return(Json(false, JsonRequestBehavior.AllowGet)); } else { return(Json(true, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// checks how much credits are remaining /// </summary> /// <param name="teacherId"></param> /// <returns>total remaining credit </returns> public JsonResult GetRemainingCreditByTeacherId(int teacherId) { CourseAssignManager aCourseAssignManager = new CourseAssignManager(); int creditToBeTaken = aCourseAssignManager.GetCreditByTeacherId(teacherId); int remainingCredit; int totalAssignedCredit = aCourseAssignManager.GetAssignedCreditByTeacherId(teacherId); if (totalAssignedCredit == 0) { remainingCredit = creditToBeTaken; } else if (totalAssignedCredit < creditToBeTaken) { remainingCredit = creditToBeTaken - totalAssignedCredit; } else { remainingCredit = creditToBeTaken - totalAssignedCredit; } return(Json(remainingCredit, JsonRequestBehavior.AllowGet)); }