} // OnDeleteRecord /// <summary> /// Método encargado de obtener todos los registros de Producto. /// </summary> /// <param name="parameter"> /// Parámetro con información adicional. /// </param> /// <remarks> /// Sin comentarios adicionales. /// </remarks> public override void OnGetRecords(object parameter) { // Si está activo y no ocupado. if (this.IsActive && !this.IsBusy) { // Ocupado. this.IsBusy = true; // Instanciamos el proxy. WcfClient.EntityBServiceReference.EntityBWebServiceClient serviceClient = new WcfClient.EntityBServiceReference.EntityBWebServiceClient(); //Ejecutamos el servicio de forma asíncrona. serviceClient.BeginGetPaged(this.Specification, /*this.userContext,*/ (asyncResult) => { // Obtenemos el resultado. PagedElements<EFApplication.Dtos.EntityBDto> result = serviceClient.EndGetPaged(asyncResult); this.Items = new ObservableCollection<EntityBViewModel>(result.Select(i => new EntityBViewModel(i))); this.TotalRecordCount = result.TotalElements; this.IsBusy = false; this.RefreshPagingCommands(); }, null); } } // OnGetRecords
public PagedElements<PersonalAccountwaterDTO> Query(DateTime beginDate, DateTime endDate, Guid userId, PagerQuery pager) { var water = _personalAccountWaterRepository.Query(beginDate, endDate, userId, pager); List<PersonalAccountwaterDTO> elements = new List<PersonalAccountwaterDTO>(); water.Elements.ToList().ForEach(t => elements.Add(Mapper.Map<PersonalAccountwaterDTO>(t))); PagedElements<PersonalAccountwaterDTO> result = new PagedElements<PersonalAccountwaterDTO>( elements, water.TotalElements); return result; }
// code generated from template "ServiceGetPaged.tt" /// <summary> /// Recupera una lista paginada de entidades Persona, según la especificación indicada. /// </summary> /// <param name="specificationDto"> /// Especificación que se va a aplicar. /// </param> /// <returns> /// La lista paginada de entidades 'Persona', según la especificación indicada. /// </returns> public PagedElements <PersonaDto> GetPaged(SpecificationDto specificationDto) { #region Preconditions // Comprobar el DTO de entrada. Guard.ArgumentIsNotNull( specificationDto, string.Format( FrameworkResource.EspecificationDataTransferObjectIsNull, "Persona")); #endregion List <PersonaDto> result = new List <PersonaDto>(0); int totalElements = 0; try { // Creamos el repositorio de la entidad. IPersonaRepository repo = ApplicationLayer.IocContainer.Resolve <IPersonaRepository>(); // Obtenemos las entidades aplicando la especificación. ISpecification <Persona> filter = specificationDto.ToSpecification <Persona>(); PagedElements <Persona> entities = repo.GetPagedElements( specificationDto.PageIndex, specificationDto.PageSize, filter.IsSatisfiedBy(), entity => entity.Id, true); totalElements = entities.TotalElements; // Mapeamos los datos. entities.ToList() .ForEach(entity => { var entityDto = this.personaMapper.EntityMapping(entity); result.Add(entityDto); }); // Confirmamos la transacción. this.Commit(); } catch (Exception ex) { throw ex; } // Devolver el resultado. return(new PagedElements <PersonaDto>(result, totalElements)); }
public void GetPaged_DescendingOrder_Test() { // Act var target = new ListRepository(); int pageIndex = 0; int pageCount = 1; // Act PagedElements <Entity> result = target.GetPaged(pageIndex, pageCount, e => true, e => e.Id, false); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.TotalElements); }
//PagedElements<Entity1Dto> GetPaged(SpecificationDto specificationDto, UserContextDto userContextDto); public PagedElements <EntityBDto> GetPaged(SpecificationDto specificationDto) { #region Preconditions // Comprobar el DTO de entrada. Guard.ArgumentIsNotNull( specificationDto, string.Format( Inflexion2.Resources.Framework.EspecificationDataTransferObjectIsNull, "Entity B")); //// usar un fichero de recursos para el dominio de negocio Company.Product.BoundedContext.Resources.Business.EntityBAlias #endregion List <EntityBDto> result = new List <EntityBDto>(0); int totalElements = 0; try { // Creamos el repositorio de la entidad. IEntityBRepository repo = this.unityContainer.Resolve <IEntityBRepository>(); // Obtenemos las entidades aplicando la especificación. ISpecification <EntityB> filter = specificationDto.ToSpecification <EntityB>(); PagedElements <EntityB> entities = repo.GetPagedElements( specificationDto.PageIndex, specificationDto.PageSize, filter.IsSatisfiedBy(), entity => entity.Id, true); totalElements = entities.TotalElements; // Mapeamos los datos. entities.ToList().ForEach(entity => { var entityDto = this.EntityBMapper.EntityMapping(entity); result.Add(entityDto); }); // Confirmamos la transacción. this.Commit(); } catch (Exception ex) { // Escribir en el Log. //logger.Error(ex.Message, ex); throw ex; } // Devolver el resultado. return(new PagedElements <EntityBDto>(result, totalElements)); }
public void GetFilteredAndOrderedAndPagedElements_InvalidPageIndexThrowArgumentException_Test() { // Act var target = new ListRepository(); int pageIndex = -1; int pageCount = 1; // Act PagedElements <Entity> result = target.GetPaged( pageIndex, pageCount, e => e.Id == 1, null, false); }
public void GetFiltered_WithDescendingOrderedAndPagedElements_Test() { // Act var target = new ListRepository(); int pageIndex = 0; int pageCount = 1; // Act PagedElements <Entity> result = target.GetPaged( pageIndex, pageCount, e => e.Id == 1, e => e.Id, false); // Assert Assert.IsTrue(result != null); Assert.IsTrue(result.TotalElements == 1); }
} // OnDeleteRecord /// <summary> /// Método encargado de obtener todos los registros de Categoria. /// </summary> /// <param name="parameter"> /// Parámetro con información adicional. /// </param> public override void OnGetRecords(object parameter) { if (!this.IsBusy) { this.IsBusy = true; // Instanciamos el proxy. CategoriaServiceClient serviceClient = new CategoriaServiceClient(); //Ejecutamos el servicio de forma asíncrona. serviceClient.BeginGetPaged(this.Specification, (asyncResult) => { // Obtenemos el resultado. PagedElements <CategoriaDto> result = serviceClient.EndGetPaged(asyncResult); this.Items = new ObservableCollection <CategoriaViewModel>(result.Select(i => new CategoriaViewModel(i))); this.TotalRecordCount = result.TotalElements; this.IsBusy = false; this.RefreshPagingCommands(); }, null); } } // OnGetRecords