public JsonResult DropDown_Class(long year, long studentId) { var result = (dynamic)null; if (year != 0) { var classes = _StudentPaymentsServ.ClassByYear(year, studentId); var model = new ClassByYear() { Id = classes.Id, Name = classes.Name }; result = Json(new { id = model.Id, name = model.Name }); } return(result); }
public ClassByYear ClassByYear(long year, long studentId) { var queryAll = _classesRepo.GetAll().ToList(); var StudentPromotion = _StudentPromotions.GetAll().ToList(); var getClasses = (from sp in StudentPromotion join c in queryAll on sp.ClassId equals c.Id where sp.ClassYear.Value.Year == year && sp.StudentId == studentId select new { sp, c }).SingleOrDefault(); var queryResult = new ClassByYear() { Id = getClasses.c.Id, Name = getClasses.c.Name }; return(queryResult); }