예제 #1
0
        public JsonResult GetTeacherCredit(int teacherId)
        {
            if (teacherId == 0 || teacherId == null)
            {
                return(Json(0, JsonRequestBehavior.AllowGet));
            }
            Teacher aTeacher = aTeacherManager.GetATeacher(teacherId);
            IEnumerable <CourseAssignTeacher> CourseAssignTeacher = aCourseAssignToTeacherManager.GetListByTeacherId(teacherId);
            TeacherCredit aTeacherCredit = new TeacherCredit();

            aTeacherCredit.TeacherCreditTo = Convert.ToDouble(aTeacher.CreditToBeTaken);
            if (CourseAssignTeacher.Count() == 0)
            {
                aTeacherCredit.RemCredit = aTeacher.CreditToBeTaken;
            }
            else
            {
                double x = 0;
                foreach (var assignList in CourseAssignTeacher)
                {
                    x += assignList.CreditTaken;
                }
                aTeacherCredit.RemCredit = Convert.ToDouble(aTeacher.CreditToBeTaken) - x;
            }
            return(Json(aTeacherCredit, JsonRequestBehavior.AllowGet));
        }