Guest User

Untitled

a guest
Oct 20th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.60 KB | None | 0 0
  1. using System;
  2. using Castle.ActiveRecord;
  3. using Novutek.Apartados.Web.Libs;
  4. using Novutek.Apartados.Web.PagingJGrid;
  5. using NHibernate;
  6. using NHibernate.Criterion;
  7. using Novutek.Apartados.Web.DTO;
  8.  
  9. namespace Novutek.Apartados.Web.Models
  10. {
  11.     /// <summary>
  12.     /// Clase del estereotipo entidad que representa la tabla de categorias,
  13.     /// la cual contiene la información sobre las categorías registradas en el sistema.
  14.     /// </summary>
  15.     [ActiveRecord("tblRecurso")]
  16.     public class DetalleRecurso : PersistentEntity<DetalleRecurso, int>
  17.     {
  18.         private int id;
  19.         private string m_nombre;
  20.         private string m_descripcion;
  21.         private bool m_activo;
  22.         private int m_idCategoria;
  23.  
  24.  
  25.         [PrimaryKey]
  26.         private int Id
  27.         {
  28.             get { return id; }
  29.             set { id = value; }
  30.         }
  31.  
  32.         [Property("nombre", NotNull = true, Length = 150, Unique = true)]
  33.         public string Nombre
  34.         {
  35.             get { return m_nombre; }
  36.             set { m_nombre = value; }
  37.         }
  38.  
  39.  
  40.         [Property("descripcion", NotNull = true)]
  41.         public string Descripcion
  42.         {
  43.             get { return m_descripcion; }
  44.             set { m_descripcion = value; }
  45.         }
  46.  
  47.         [Property("activo", NotNull = true, Default = "false")]
  48.         public bool Activo
  49.         {
  50.             get { return m_activo; }
  51.             set { m_activo = value; }
  52.         }
  53.  
  54.         [HasAndBelongsToMany(typeof(Categoria),
  55.             Table="tblCategoria",ColumnKey="IdCategoria", ColumnRef="Id", Inverse=true)]
  56.         public int IdCategoria
  57.         {
  58.             get { return m_idCategoria; }
  59.             set { m_idCategoria = value; }
  60.         }
  61.  
  62.  
  63.         public PagingResult<DetalleRecursoDTO> GetDetalleRecurso(PagingConfig config)
  64.         {
  65.             ICriteria criteria = DetalleRecurso.GetCriteria();
  66.             //criteria.CreateAlias("CatalogoEjemplo", "catalogoEjemplo");
  67.  
  68.             //restricciones
  69.             //if (codigo != null && !String.IsNullOrWhiteSpace(codigo))
  70.             //{
  71.             //    criteria.Add(Restrictions.Like("blank." + CODIGO_PARAM, codigo, MatchMode.Anywhere));
  72.             //}
  73.             //if (tipo == 1)
  74.             //{
  75.             //    criteria.Add(Restrictions.Eq("blank." + ACTIVO_PARAM, true));
  76.             //}
  77.  
  78.             ProjectionList proyecciones = Projections.ProjectionList();
  79.             proyecciones.Add(Projections.Property("Id"), "Id");
  80.             proyecciones.Add(Projections.Property("Nombre"), "Nombre");
  81.             proyecciones.Add(Projections.Property("Descripcion"), "Descripcion");
  82.             proyecciones.Add(Projections.Property("Activo"), "Activo");
  83.             proyecciones.Add(Projections.Property("IdCategoria"), "IdCategoria");
  84.  
  85.  
  86.             PagingResult<DetalleRecursoDTO> lista = List<DetalleRecursoDTO>(config, criteria, proyecciones);
  87.  
  88.             //foreach (CatalogoEjemploDTO b in lista.Rows)
  89.             //{
  90.             //    CatalogoEjemplo elemento = new CatalogoEjemplo();
  91.             //    elemento = elemento.ObtenerBlankPorId(b.Id);
  92.             //    StringBuilder strPartes = new StringBuilder();
  93.  
  94.             //    for (int i = 0; i < elemento.Partes.Count; i++)
  95.             //    {
  96.             //        strPartes.Append(elemento.Partes[i].Nombre);
  97.             //        if (i + 1 < elemento.Partes.Count)
  98.             //        {
  99.             //            strPartes.Append(", ");
  100.             //        }
  101.             //    }
  102.             //    b.Partes = strPartes.ToString();
  103.             //}
  104.  
  105.             return lista;
  106.         }
  107.  
  108.  
  109.     }
  110. }
Add Comment
Please, Sign In to add comment