} // Name #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> /// <returns> /// Devuelve el objeto Dto <see cref="CategoriaDto"/> correspondiente. /// </returns> public override CategoriaDto GetById(Int32 identifier) { CategoriaServiceClient serviceClient = new CategoriaServiceClient(); // Consumimos el servicio y obtenemos los datos. var categoriaDto = serviceClient.GetById(identifier); // Devolvemos la respuesta. return(categoriaDto); } // GetById
public void RegistrarCategoria() { var proxiesCategoria = new CategoriaServiceClient(); var addCategoria = new CategoriaDTO() { CategoriaId = CategoriaId, Descripcion = Descripcion }; proxiesCategoria.CrearCategoriaAsync(addCategoria); ListCategoria.Add(addCategoria); MessageBox.Show("La Categoria ha sido Registrado"); }
} // GetById /// <summary> /// Método encargado de crear o actualizar una entidad de tipo Categoria. /// </summary> /// <param name="parameter"> /// Parámetro con información adicional. /// </param> public override void OnSaveRecord(object parameter) { if (this.IsActive && (this.ObjectElement != null)) { CategoriaServiceClient serviceClient = new CategoriaServiceClient(); if (this.ObjectElement.Id == default(Int32)) { serviceClient.Create(this.ObjectElement); this.MessageBoxService.Show("Entidad agregada"); } else { bool response = serviceClient.Update(this.ObjectElement); this.MessageBoxService.Show("Entidad actualizada"); } } } // OnSaveRecord
public void ObtenerCqategoria() { var proxiesCategoria = new CategoriaServiceClient(); var Categoria = proxiesCategoria.ObtenerCategoria(); if (Categoria != null) { foreach (var item in Categoria) { var obtenerCategoria = new CategoriaDTO { CategoriaId = item.CategoriaId, Descripcion = item.Descripcion }; ListCategoria.Add(obtenerCategoria); ListCategoriaOriginal.Add(obtenerCategoria); } } proxiesCategoria.ObtenerCategoriaAsync(); }
/// <summary> /// Método público encargado del borrado de una entidad . /// </summary> /// <param name="parameter"> /// Parámetro con información adicional. /// </param> public override void OnDeleteRecord(object parameter) { try { if (this.IsActive && this.SelectedItem != null) { // Instanciamos el proxy. CategoriaServiceClient serviceClient = new CategoriaServiceClient(); // Ejecutamos el servicio. bool result = serviceClient.Delete(this.SelectedItem.Id); if (result) { 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
} // 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
public void ObtenerCqategoria() { var proxiesCategoria = new CategoriaServiceClient(); var Categoria = proxiesCategoria.ObtenerCategoria(); if (Categoria!=null) { foreach (var item in Categoria) { var obtenerCategoria = new CategoriaDTO { CategoriaId = item.CategoriaId, Descripcion = item.Descripcion }; ListCategoria.Add(obtenerCategoria); ListCategoriaOriginal.Add(obtenerCategoria); } } proxiesCategoria.ObtenerCategoriaAsync(); }