public JsonResult GetAllUsers(int Id, string searchTerm, int pageSize = 0, int pageNum = 0) { List <User> users; if (searchTerm == null) { users = _userService.GetAllUsers(k => k.Id != Id, take: pageSize, skip: (pageNum * pageSize) - 100); } else { users = _userService.GetAllUsers(k => k.Name.Contains(searchTerm), take: pageSize, skip: (pageNum * pageSize) - 100); } var result = new { Total = users.Count(), Results = Select2ModelConst <User, UserMap> .Select2ModelComponent(users) }; return(new JsonResult { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult GetDepartments(string searchTerm, int pageSize = 0, int pageNum = 0) { List <Department> departments; if (searchTerm == null) { departments = _departmentService.GetAllDepartments(take: pageSize, skip: (pageNum * pageSize) - 100); } else { departments = _departmentService.GetAllDepartments(k => k.Name.Contains(searchTerm) || k.Description.Contains(searchTerm), take: pageSize, skip: (pageNum * pageSize) - 100); } var result = new { Total = departments.Count(), Results = Select2ModelConst <Department, DepartmentMap> .Select2ModelComponent(departments) }; return(new JsonResult { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }