//public ActionResult Director_Read([DataSourceRequest]DataSourceRequest request) //{ // Director[] directors = null; // int directorCount = _directorService.GetAll().Count(); ////////////////////////////// // RunAndReleaseProxy<IDirectorService>(_proxyFactory.CreateProxy<IDirectorService>(), proxy => // { // directors = proxy.GetByPage(request.Page, request.PageSize); // directorCount = proxy.TotalCount(); // }); // return Json(new DataSourceResult // { // Data = directors, // Total = directorCount // }); //} public ActionResult Director_Read([DataSourceRequest] DataSourceRequest request, string searchTerm) { if (searchTerm.IsNullOrWhiteSpace()) { Director[] directors = _directorService.GetByPage(request.Page, request.PageSize); int movieCount = _directorService.TotalCount(); return(Json(new DataSourceResult { Data = directors, Total = movieCount })); } else { Director[] directors = _directorService.FindByName(searchTerm).Select(data => new Director() { FullName = data.Name, Id = data.Id }).ToArray(); int movieCount = directors.Count(); return(Json(new DataSourceResult { Data = directors, Total = movieCount })); } }