} // 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
Esempio n. 2
0
        } // Nombre Property

        ///// <summary>
        ///// Propiedad pública que obtiene o establece la descripción de la entidad.
        ///// </summary>
        ///// <remarks>
        ///// Sin comentarios adicionales.
        ///// </remarks>
        ///// <value>
        ///// Valor que es utilizado para obtener o establecer la descripción de la entidad.
        ///// </value>
        //public string Descripcion
        //{
        //    get
        //    {
        //        return this.ObjectElement.Descripcion;
        //    }
        //    set
        //    {
        //        if (this.ObjectElement.Descripcion != value)
        //        {
        //            this.ObjectElement.Descripcion = value;
        //            this.RaisePropertyChanged(() => this.Descripcion);
        //        }
        //    }
        //} // Descripcion Property


        ///// <summary>
        ///// Obtiene o establece el código externo de la entidad.
        ///// </summary>
        ///// <value>
        ///// Codigo externo de la entidad.
        ///// </value>
        //public string CodigoExterno
        //{
        //    get
        //    {
        //        return this.ObjectElement.CodigoExterno;
        //    }
        //    set
        //    {
        //        if (this.ObjectElement.CodigoExterno != value)
        //        {
        //            this.ObjectElement.CodigoExterno = value;
        //            this.RaisePropertyChanged(() => this.CodigoExterno);
        //        }
        //    }
        //}


        ///// <summary>
        ///// Obtiene o establece el Nombre del Soporte de la entidad.
        ///// </summary>
        ///// <value>
        ///// Nombre Del Soporte de la entidad.
        ///// </value>
        //public string NombreSoporte
        //{
        //    get
        //    {
        //        return this.ObjectElement.NombreSoporte;
        //    }
        //    set
        //    {
        //        if (this.ObjectElement.NombreSoporte != value)
        //        {
        //            this.ObjectElement.NombreSoporte = value;
        //            this.RaisePropertyChanged(() => this.NombreSoporte);
        //        }
        //    }
        //}

        ///// <summary>
        ///// Obtiene o establece el Nombre del Ambito de la entidad.
        ///// </summary>
        ///// <value>
        ///// Nombre Del Ambito de la entidad.
        ///// </value>
        //public string NombreAmbito
        //{
        //    get
        //    {
        //        return this.ObjectElement.NombreAmbito;
        //    }
        //    set
        //    {
        //        if (this.ObjectElement.NombreAmbito != value)
        //        {
        //            this.ObjectElement.NombreAmbito = value;
        //            this.RaisePropertyChanged(() => this.NombreAmbito);
        //        }
        //    }
        //}


        /////<summary>
        ///// Propiedad pública encargada de obtener y establecer el Visible Extranet
        ///// de la entidad.
        ///// </summary>
        ///// <remarks>
        ///// Sin comentarios adicionales.
        ///// </remarks>
        ///// <value>
        ///// Indica el campo Visibl extranet de la entidad.
        ///// </value>
        //public bool EsVisibleExtranet
        //{
        //    get
        //    {
        //        return this.ObjectElement.EsVisibleExtranet;
        //    }
        //    set
        //    {
        //        if (this.ObjectElement.EsVisibleExtranet != value)
        //        {
        //            this.ObjectElement.EsVisibleExtranet = value;
        //            RaisePropertyChanged(() => this.EsVisibleExtranet);
        //        }
        //    }
        //} // GestionaPosiciones

        /////<summary>
        ///// Propiedad pública encargada de obtener y establecer la hora
        ///// de inicio de emisión de la desconexión
        ///// </summary>
        ///// <value>
        ///// Indica el campo hora de inicio de emisión
        ///// </value>
        //public DateTime? HoraInicioEmision
        //{
        //    get
        //    {
        //        return this.ObjectElement.HoraInicioEmision;
        //    }
        //    set
        //    {
        //        if (this.ObjectElement.HoraInicioEmision != value)
        //        {
        //            this.ObjectElement.HoraInicioEmision = value;
        //            RaisePropertyChanged(() => this.HoraInicioEmision);
        //        }
        //    }
        //} // HoraInicioEmision

        /////<summary>
        ///// Propiedad pública encargada de obtener y establecer la hora
        ///// de fin de emisión de la desconexión
        ///// </summary>
        ///// <value>
        ///// Indica el campo hora de fin de emisión
        ///// </value>
        //public DateTime? HoraFinEmision
        //{
        //    get
        //    {
        //        return this.ObjectElement.HoraFinEmision;
        //    }
        //    set
        //    {
        //        if (this.ObjectElement.HoraFinEmision != value)
        //        {
        //            this.ObjectElement.HoraFinEmision = value;
        //            RaisePropertyChanged(() => this.HoraFinEmision);
        //        }
        //    }
        //} // HoraFinEmision

        ///// <summary>
        ///// Indica el soporte seleccionado
        ///// </summary>
        //public int SelectedSoporteValue
        //{
        //    get
        //    {
        //        return this.ObjectElement.SoporteId;
        //    }
        //    set
        //    {
        //        if (this.ObjectElement.SoporteId != value)
        //        {
        //            this.ObjectElement.SoporteId = value;
        //            RaisePropertyChanged(() => this.SelectedSoporteValue);
        //        }
        //    }
        //}

        //private ObservableCollection<IKeyValueItem> soportes;
        //public ObservableCollection<IKeyValueItem> Soportes
        //{
        //    get
        //    {
        //        return this.soportes;
        //    }
        //    set
        //    {
        //        if (this.soportes != value)
        //        {
        //            this.soportes = value;
        //            RaisePropertyChanged(() => this.Soportes);
        //        }
        //    }
        //}

        //public ICommand RefreshSoportes { get { return new RelayCommand(LoadSoportes); } }


        ////Combo Ambito
        //public int SelectedAmbitoValue
        //{
        //    get
        //    {
        //        return this.ObjectElement.AmbitoId;
        //    }
        //    set
        //    {
        //        if (this.ObjectElement.AmbitoId != value)
        //        {
        //            this.ObjectElement.AmbitoId = value;
        //            RaisePropertyChanged(() => this.SelectedAmbitoValue);
        //        }
        //    }
        //}

        //private ObservableCollection<IKeyValueItem> ambitos;
        //public ObservableCollection<IKeyValueItem> Ambitos
        //{
        //    get
        //    {
        //        return this.ambitos;
        //    }
        //    set
        //    {
        //        if (this.ambitos != value)
        //        {
        //            this.ambitos = value;
        //            RaisePropertyChanged(() => this.Ambitos);
        //        }
        //    }
        //}

        //public ICommand RefreshAmbitos { get { return new RelayCommand(LoadAmbitos); } }


        //private ObservableCollection<IKeyValueItem> grupoProductoes;
        //public ObservableCollection<IKeyValueItem> GrupoProductoes
        //{
        //    get
        //    {
        //        return this.grupoProductoes;
        //    }
        //    set
        //    {
        //        if (this.grupoProductoes != value)
        //        {
        //            this.grupoProductoes = value;
        //            RaisePropertyChanged(() => this.GrupoProductoes);
        //        }
        //    }
        //}

        //public ICommand RefreshGrupoProductoes { get { return new RelayCommand(LoadGrupoProductoes); } }

        //#endregion

        #region METHODS

        /// <summary>
        /// Método encargado de recuperar los datos de una entidad mediante su identificador.
        /// </summary>
        /// <param name="identifier">
        /// Parámetro que indica el identificador de la entidad que se va a recuperar.
        /// </param>
        /// <remarks>
        /// Sin comentarios adicionales.
        /// </remarks>
        /// <returns>
        /// Devuelve el objeto Dto <see cref="MedioDto"/> correspondiente.
        /// </returns>
        public override EntityBDto GetById(int identifier)
        {
            //UserContextDto userContext = ApplicationContext.UserContext;
            WcfClient.EntityBServiceReference.EntityBWebServiceClient serviceClient = new WcfClient.EntityBServiceReference.EntityBWebServiceClient();

            // Consumimos el servicio y obtenemos los datos.
            var ProductoDto = serviceClient.GetById(identifier /*, userContext*/);

            // Devolvemos la respuesta.
            return(ProductoDto);
        } // GetById
        } // OnActivateRecord

        /// <summary>
        /// Método público encargado del borrado de una entidad .
        /// </summary>
        /// <param name="parameter">
        /// Parámetro con información adicional.
        /// </param>
        /// <remarks>
        /// Sin comentarios adicionales.
        /// </remarks>
        public override void OnDeleteRecord(object parameter)
        {
            try
            {
                if (this.IsActive && this.SelectedItem != null)
                {
                    // Instanciamos el proxy.

                    WcfClient.EntityBServiceReference.EntityBWebServiceClient serviceClient = new WcfClient.EntityBServiceReference.EntityBWebServiceClient();
                    // Ejecutamos el servicio.
                    bool result = serviceClient.Delete(
                                                        this.SelectedItem.Id
                                                    /*, this.userContext*/);
                    if (result)
                    {
                        // Desactivamos
                        //this.SelectedItem.Activo = false;
                        this.MessageBoxService.Show(
                                                    "El registro se ha borrado correctamente.", /* TODO pass to resources borrar/ deshabilitar */
                                                    Application.Current.MainWindow.Title,
                                                    MessageBoxButton.OK,
                                                    MessageBoxImage.Information);
                        this.RefreshCommands();
                    }
                    else
                    {
                        this.MessageBoxService.Show(
                                                    "¡Ha sido imposible borrar el registro!",/* TODO pass to resources borrar / deshabilitar*/
                                                    Application.Current.MainWindow.Title,
                                                    MessageBoxButton.OK,
                                                    MessageBoxImage.Exclamation);
                    }
                }
            }
            catch (System.Exception ex)
            {
                this.MessageBoxService.Show(
                                            string.Format(
                                                          "¡Se ha producido un error al intentar borrar el registro!\r\n\r\n{0}",
                                                          ex.Message),
                                            Application.Current.MainWindow.Title,
                                            MessageBoxButton.OK,
                                            MessageBoxImage.Error);
            }
        } // OnDeleteRecord
Esempio n. 4
0
        } // GetById

        /// <summary>
        /// Método encargado de crear o actualizar una entidad de tipo Medio.
        /// </summary>
        /// <remarks>
        /// Sin comentarios adicionales.
        /// </remarks>
        /// <param name="parameter">
        /// Parámetro con información adicional.
        /// </param>
        public override void OnSaveRecord(object parameter)
        {
            if (this.IsActive &&
                (this.ObjectElement != null))
            {
                //UserContextDto userContext = ApplicationContext.UserContext;

                WcfClient.EntityBServiceReference.EntityBWebServiceClient serviceClient = new WcfClient.EntityBServiceReference.EntityBWebServiceClient();

                if (this.ObjectElement.Id == default(int))
                {
                    serviceClient.Create(this.ObjectElement /*, userContext*/);
                    this.MessageBoxService.Show("Entidad agregada");
                }
                else
                {
                    bool response = serviceClient.Update(this.ObjectElement /*, userContext*/);
                    this.MessageBoxService.Show("Entidad actualizada");
                }
            }
        } // OnSaveRecord