public List <Course> CoursesForCB(string id) { IEnumerable <CourseStudent> courseStudents = new List <CourseStudent>(); courseStudents = _courseStudentData.FindAllByStudent(id); List <Course> courses = new List <Course>(); foreach (CourseStudent courseStudent in courseStudents) { courses.Add(courseStudent.Course); } return(courses); }
public IActionResult CoursesStudent(string id) { var model = _courseStudentData.FindAllByStudent(id); Console.WriteLine("ID: ++++++++++++++++++" + id); var draw = HttpContext.Request.Form["draw"].FirstOrDefault(); var start = Request.Form["start"].FirstOrDefault(); var length = Request.Form["length"].FirstOrDefault(); var sortColumn = Request.Form["columns[" + Request.Form["order[0][column]"].FirstOrDefault() + "][name]"].FirstOrDefault(); var sortColumnDirection = Request.Form["order[0][dir]"].FirstOrDefault(); var searchValue = Request.Form["search[value]"].FirstOrDefault(); int pageSize = length != null?Convert.ToInt32(length) : 0; int skip = start != null?Convert.ToInt32(start) : 0; int recordsTotal = 0; Console.WriteLine(model.ToList().Count + "------------------------------DUZINA SLUSANJAAA"); Console.WriteLine("SOrt colummmmmmmmmmmmn --" + sortColumn); /* if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDirection))) * { * var sortProperty = typeof(Slusa).GetProperty(sortColumn); * if (sortColumnDirection == "asc") * { * model = model.OrderBy(p => sortProperty.GetValue(p, null)); * } * if (sortColumnDirection == "desc") * { * model = model.OrderByDescending(p => sortProperty.GetValue(p, null)); * } * }*/ if (!string.IsNullOrEmpty(searchValue)) { model = model.Where(m => m.StudentID.StartsWith(searchValue, true, null)); } recordsTotal = model.Count(); var data = model.Skip(skip).Take(pageSize).ToList(); return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = data })); }