public IEnumerable <AllColleges> Colleges(int id) { int val = 0; if (int.TryParse(id.ToString(), out val)) { using (UOSEntities db = new UOSEntities()) { var data = db.bi_get_affi_clgs_with_pagination(val); List <AllColleges> listobj = new List <AllColleges>(); foreach (var item in data) { AllColleges obj = new AllColleges(); obj.id = item.ID.ToString(); obj.collegeName = item.Ins_Name; obj.isGovCollege = item.Ins_IsGov == true ? true : false; obj.collegeCode = item.Inst_code.ToString(); listobj.Add(obj); } return(listobj); } } else { List <AllColleges> listobj = new List <AllColleges>(); return(listobj); } }