public async Task OnGetAsync(string searchString, int?currentPage, int?pageSize) { PageSize = pageSize.HasValue ? pageSize.Value : PaginationConstants.DefaultPageSize; if (!string.IsNullOrEmpty(searchString)) { SearchString = searchString; TotalItems = await _repository.CountAsync(new AlumnoSpec(new AlumnoFilter { Apellido = searchString, IsPagingEnabled = false })); } else { TotalItems = await _repository.CountAsync(new AlumnoSpec(new AlumnoFilter { IsPagingEnabled = false })); } Pager = new Pager(TotalItems, currentPage.HasValue ? currentPage.Value : PaginationConstants.DefaultPage, PageSize); var filter = new AlumnoFilter(); filter.IsPagingEnabled = true; filter.Apellido = searchString; filter.PageSize = Pager.PageSize; filter.Page = Pager.CurrentPage; Alumnos = await _repository.ListAsync(new AlumnoSpec(filter)); }
public async Task OnGetAsync(string searchString, int?currentPage, int?sizePage) { var idUserCookie = (((ClaimsIdentity)User.Identity).FindFirst(ClaimTypes.NameIdentifier).Value); int idUsuario = Convert.ToInt32(idUserCookie); if (searchString != null) { var totalItems = await _repository.CountAsync(new Paquete_UserSpec(new Paquete_Filter { UserId = idUsuario, Contenido_Paquete = searchString, LoadChildren = false, IsPagingEnabled = true })); UIPagination = new UIPaginationModel(currentPage, searchString, sizePage, totalItems); Paquetes = await _repository.ListAsync(new Paquete_Spec( new Paquete_Filter { IsPagingEnabled = true, Contenido_Paquete = UIPagination.SearchString, SizePage = UIPagination.GetSizePage, Page = UIPagination.GetCurrentPage }) ); } Paquetes = await _repository.ListAsync(new Paquete_UserSpec(new Paquete_Filter { UserId = idUsuario })); }
public async Task OnGet(string searchString, int?currentPage, int?sizePage) { try { var totalItems = await _repository.CountAsync(new TipoNegocioSpec( new TipoNegocioFilter { Nombre = searchString, LoadChildren = false, IsPagingEnabled = true })); UIPagination = new UIPaginationModel(currentPage, searchString, sizePage, totalItems); TiposNegocio = await _repository.ListAsync(new TipoNegocioSpec( new TipoNegocioFilter { IsPagingEnabled = true, Nombre = UIPagination.SearchString, PageSize = UIPagination.GetPageSize, Page = UIPagination.GetCurrentPage, LoadChildren = false } )); } catch (Exception ex) { _logger.LogWarning(ex.Message); throw; } }
public async Task OnGetAsync(string searchString, string typeFilter, int?currentPage, int?sizePage) { if (typeFilter == "") { typeFilter = "Alquiler"; } var totalItems = await _repository.CountAsync(new AlquilerSpec(new AlquilerFilter { LoadChildren = true, IsPagingEnabled = true })); UIPagination = new UIPaginationModel(currentPage, searchString, sizePage, totalItems); Alquileres = await _repository.ListAsync(new AlquilerSpec( new AlquilerFilter { IsPagingEnabled = true, TypeFilter = typeFilter, SearchString = searchString, // = UIPagination.SearchString, SizePage = UIPagination.GetSizePage, Page = UIPagination.GetCurrentPage, LoadChildren = true }) ); }
public async Task <IActionResult> OnGetAsync(int?categoriaId, string searchString, int?currentPage, int?sizePage) { try { if (!categoriaId.HasValue) { _notifyService.Warning($"Debe selecionar una categoria para ver sus negocios"); return(RedirectToPage("Index", new { area = "Categorias" })); } Categoria = await _categoriaRepository.GetByIdAsync(categoriaId.Value); if (Categoria == null) { _notifyService.Warning($"No se ha encontrado una categoria con el id {categoriaId.Value}"); return(RedirectToPage("Index", new { area = "Categorias" })); } var totalItems = await _repository.CountAsync(new NegocioSpec( new NegocioFilter { CategoriaId = categoriaId.Value, Nombre = searchString, LoadChildren = false, IsPagingEnabled = true })); UIPagination = new UIPaginationModel(currentPage, searchString, sizePage, totalItems); Negocios = await _repository.ListAsync(new NegocioSpec( new NegocioFilter { IsPagingEnabled = true, Nombre = UIPagination.SearchString, CategoriaId = categoriaId.Value, PageSize = UIPagination.GetPageSize, Page = UIPagination.GetCurrentPage, LoadChildren = true }) ); return(Page()); } catch (Exception ex) { _logger.LogWarning(ex.Message); return(RedirectToPage("Index", new { area = "Categorias" })); } }
public async Task OnGetAsync(string searchString, int?currentPage, int?sizePage) { var totalItems = await _repository.CountAsync(new AutoSpec(new AutoFilter { Marca = searchString, LoadChildren = false, IsPagingEnabled = true })); UIPagination = new UIPaginationModel(currentPage, searchString, sizePage, totalItems); Auto = await _repository.ListAsync(new AutoSpec( new AutoFilter { IsPagingEnabled = true, Marca = UIPagination.SearchString, SizePage = UIPagination.GetSizePage, Page = UIPagination.GetCurrentPage }) ); }
public void Test_RepositorReadOnlyExtendedAsync() { //Insert TestInsert10Assember(); //Select a Randon index between 0 and 9 and get name selected int ind = new Random().Next(0, 9); string assembler = assmblers[ind]; //Create Repository IRepositoryReadOnlyExtendedAsync <Assembler> RoRepository = new MyRepository <Assembler, MyContext>(this.uow, "Assemblers", new KeyValuePair <string, Type>("id", typeof(int))); //Test Count method Assert.AreEqual(10, RoRepository.CountAsync(f => 1 == 1).Result); //Test FindAll Assert.IsTrue(RoRepository.ExistsAsync(f => f.name == assembler).Result); //Delete TestClearDb(); }
/// <inheritdoc/> public Task <int> CountAsync(Specification.ISpecification <T> specification, CancellationToken cancellationToken = default) { // TODO: Add Caching return(_sourceRepository.CountAsync(specification, cancellationToken)); }