public JsonResult GetRemainingCredit(string Id) { List <Teacher> creditTaken = teacherManager.GetCreditTaken(Id); bool CheckEntry = courseAssignManager.CheckAssignCourseEntry(Id); if (CheckEntry) { string TotalCredit = courseAssignManager.GetTotalCredit(Id); double TotalCredits = Convert.ToDouble(TotalCredit); foreach (var i in creditTaken) { CreditToken = i.CreditToken; } double RemainingCredit = CreditToken - TotalCredits; foreach (var i in creditTaken) { i.CreditToken = RemainingCredit; } } else { foreach (var i in creditTaken) { ViewBag.Res = i.CreditToken; } } return(Json(creditTaken)); }