public async Task <IActionResult> GetTotalQtyByFilters([FromQuery] UserFiltersViewModel filtersVM) { try { var filtersDto = _mapper.Map <UserFiltersViewModel, UserFiltersDto>(filtersVM); int qty = await _userUseCases.GetTotalQtyByFilters(filtersDto); return(Ok(qty)); } catch (Exception e) { throw e; } }
public JsonResult ObtenerLista(UserFiltersViewModel ofilters)//DataTableAjaxPostModel model { UserBL oUserBL = new UserBL(); //UserFiltersViewModel ofilters = new UserFiltersViewModel(); GridModel <UserViewModel> grid = oUserBL.ObtenerLista(ofilters); return(Json(new { // this is what datatables wants sending back draw = ofilters.draw, recordsTotal = grid.total, recordsFiltered = grid.recordsFiltered, data = grid.rows })); }
public async Task <IActionResult> GetByFiltersPageAndQty([FromQuery] UserFiltersViewModel filtersVM, int skip, int qty) { try { var filtersDto = _mapper.Map <UserFiltersViewModel, UserFiltersDto>(filtersVM); IEnumerable <UserDto> usersDto = await _userUseCases.GetFilteredByPageAndQty(filtersDto, skip, qty); IEnumerable <UserViewModel> usersVM = _mapper.Map <IEnumerable <UserDto>, IEnumerable <UserViewModel> >(usersDto); return(Ok(usersVM)); } catch (Exception e) { throw e; } }
public GridModel <UserViewModel> ObtenerLista(UserFiltersViewModel filters) { var searchBy = (filters.search != null) ? filters.search.value : null; string sortBy = ""; string sortDir = ""; if (filters.order != null) { // in this example we just default sort on the 1st column sortBy = filters.columns[filters.order[0].column].data; sortDir = filters.order[0].dir.ToLower(); } GridModel <UserViewModel> resultado = new GridModel <UserViewModel>(); IQueryable <users> queryFilters = Set; int count_records = queryFilters.Count(); int count_records_filtered = count_records; if (String.IsNullOrWhiteSpace(searchBy) == false) { // as we only have 2 cols allow the user type in name 'firstname lastname' then use the list to search the first and last name of dbase var searchTerms = searchBy.Split(' ').ToList().ConvertAll(x => x.ToLower()); queryFilters = queryFilters.Where(s => searchTerms.Any(srch => s.user_name.ToLower().Contains(srch) || s.user_email.ToLower().Contains(srch) || s.roles.role.ToLower().Contains(srch) || s.doc_nro.ToLower().Contains(srch))); count_records_filtered = queryFilters.Count(); } var query = queryFilters.Select(a => new UserViewModel { id = a.id, user_name = a.user_name, user_email = a.user_email, user_pass = a.user_pass, user_role = a.roles.role, document_type = a.document_types.name, doc_nro = a.doc_nro, user_status = a.user_status.name, }); if (String.IsNullOrEmpty(sortBy)) { sortBy = "id"; } if (String.IsNullOrEmpty(sortDir)) { sortDir = "asc"; } string sortExpression = sortBy.Trim() + " " + sortDir.Trim(); if (sortExpression.Trim() != "") { query = OrderByDinamic.OrderBy <UserViewModel>(query, sortExpression.Trim()); } resultado.rows = query.Skip(filters.start).Take(filters.length).ToList(); resultado.total = count_records; resultado.recordsFiltered = count_records_filtered; return(resultado); }
public GridModel <UserViewModel> ObtenerLista(UserFiltersViewModel filters) { return(oRepositorio.ObtenerLista(filters)); }