public IPagedList <AssetDto> SearchAssets(SearchAssetsInput searchInput) { int currentPageIndex = searchInput.Page.HasValue ? searchInput.Page.Value - 1 : 0; if (searchInput.Query == null) { searchInput.Query = ""; } else { searchInput.Query = searchInput.Query.ToLower(); } var @entities = _assetRepository.GetAll(); int totalCount = @entities.Count(); @entities = @entities.Where(c => c.IsDeleted != null && c.IsDeleted.Value == false && c.CompanyName.Equals(searchInput.CompanyName) && ((c.Name.ToLower().Contains(searchInput.Query) || c.Code.ToLower().Contains(searchInput.Query)) || c.Brand.ToLower().Contains(searchInput.Query) || c.Brand.ToLower().Equals(searchInput.Query) || c.Category.Name.ToLower().Contains(searchInput.Query) || c.Category.Name.ToLower().Equals(searchInput.Query) || c.ModelStr.ToLower().Contains(searchInput.Query) || c.ModelStr.ToLower().Equals(searchInput.Query) || c.Plate.ToLower().Contains(searchInput.Query) || c.Plate.ToLower().Equals(searchInput.Query) || c.Series.ToLower().Contains(searchInput.Query) || c.Series.ToLower().Equals(searchInput.Query))); return(@entities.OrderByDescending(p => p.Code).Skip(currentPageIndex * searchInput.MaxResultCount).Take(searchInput.MaxResultCount).MapTo <List <AssetDto> >().ToPagedList(currentPageIndex, searchInput.MaxResultCount, totalCount)); }
public ViewResultBase SearchDebounce(string query) { SearchAssetsInput model = new SearchAssetsInput(); try { model.Query = query; model.CompanyName = _currentUser.CompanyName; model.Entities = _assetService.SearchAssets(model); model.Control = "Asset"; model.Action = "Search"; model.ErrorCode = ErrorCodeHelper.Ok; model.ErrorDescription = ""; } catch (Exception e) { model.ErrorCode = ErrorCodeHelper.Error; model.ErrorDescription = "Error al buscar los Artículos"; } if (Request.IsAjaxRequest()) { return(PartialView("_assetListPartial", model)); } return(View("Index", model)); }
public ActionResult Index(int?page) { SearchAssetsInput model = new SearchAssetsInput(); try { model.Query = ""; model.CompanyName = _currentUser.CompanyName; model.Entities = _assetService.SearchAssets(model); model.Control = "Asset"; model.Action = "Search"; model.ErrorCode = ErrorCodeHelper.Ok; model.ErrorDescription = ""; } catch (Exception e) { model.ErrorCode = ErrorCodeHelper.Error; model.ErrorDescription = "Error al buscar los Artículos"; } return(View(model)); }
public ViewResultBase Search(SearchAssetsInput model) { try { model.CompanyName = _currentUser.CompanyName; var entities = _assetService.SearchAssets(model); model.Entities = entities; model.ErrorCode = ErrorCodeHelper.Ok; model.ErrorDescription = ""; } catch (Exception e) { model.ErrorCode = ErrorCodeHelper.Error; model.ErrorDescription = "Error al buscar los Artículos"; } if (Request.IsAjaxRequest()) { return(PartialView("_assetListPartial", model)); } return(View("Index", model)); }
public ActionResult AjaxPage(string query, int?page) { SearchAssetsInput model = new SearchAssetsInput(); model.Page = page; model.Query = query; try { model.CompanyName = _currentUser.CompanyName; model.Entities = _assetService.SearchAssets(model); model.ErrorCode = ErrorCodeHelper.Ok; model.ErrorDescription = ""; } catch (Exception) { model.ErrorCode = ErrorCodeHelper.Error; model.ErrorDescription = "Error al buscar las Ubicaciones"; } return(PartialView("_assetListPartial", model)); }