Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Castle.ActiveRecord;
- using Novutek.Apartados.Web.Libs;
- using Novutek.Apartados.Web.PagingJGrid;
- using NHibernate;
- using NHibernate.Criterion;
- using Novutek.Apartados.Web.DTO;
- namespace Novutek.Apartados.Web.Models
- {
- /// <summary>
- /// Clase del estereotipo entidad que representa la tabla de categorias,
- /// la cual contiene la información sobre las categorías registradas en el sistema.
- /// </summary>
- [ActiveRecord("tblRecurso")]
- public class DetalleRecurso : PersistentEntity<DetalleRecurso, int>
- {
- private int id;
- private string m_nombre;
- private string m_descripcion;
- private bool m_activo;
- private int m_idCategoria;
- [PrimaryKey]
- private int Id
- {
- get { return id; }
- set { id = value; }
- }
- [Property("nombre", NotNull = true, Length = 150, Unique = true)]
- public string Nombre
- {
- get { return m_nombre; }
- set { m_nombre = value; }
- }
- [Property("descripcion", NotNull = true)]
- public string Descripcion
- {
- get { return m_descripcion; }
- set { m_descripcion = value; }
- }
- [Property("activo", NotNull = true, Default = "false")]
- public bool Activo
- {
- get { return m_activo; }
- set { m_activo = value; }
- }
- [HasAndBelongsToMany(typeof(Categoria),
- Table="tblCategoria",ColumnKey="IdCategoria", ColumnRef="Id", Inverse=true)]
- public int IdCategoria
- {
- get { return m_idCategoria; }
- set { m_idCategoria = value; }
- }
- public PagingResult<DetalleRecursoDTO> GetDetalleRecurso(PagingConfig config)
- {
- ICriteria criteria = DetalleRecurso.GetCriteria();
- //criteria.CreateAlias("CatalogoEjemplo", "catalogoEjemplo");
- //restricciones
- //if (codigo != null && !String.IsNullOrWhiteSpace(codigo))
- //{
- // criteria.Add(Restrictions.Like("blank." + CODIGO_PARAM, codigo, MatchMode.Anywhere));
- //}
- //if (tipo == 1)
- //{
- // criteria.Add(Restrictions.Eq("blank." + ACTIVO_PARAM, true));
- //}
- ProjectionList proyecciones = Projections.ProjectionList();
- proyecciones.Add(Projections.Property("Id"), "Id");
- proyecciones.Add(Projections.Property("Nombre"), "Nombre");
- proyecciones.Add(Projections.Property("Descripcion"), "Descripcion");
- proyecciones.Add(Projections.Property("Activo"), "Activo");
- proyecciones.Add(Projections.Property("IdCategoria"), "IdCategoria");
- PagingResult<DetalleRecursoDTO> lista = List<DetalleRecursoDTO>(config, criteria, proyecciones);
- //foreach (CatalogoEjemploDTO b in lista.Rows)
- //{
- // CatalogoEjemplo elemento = new CatalogoEjemplo();
- // elemento = elemento.ObtenerBlankPorId(b.Id);
- // StringBuilder strPartes = new StringBuilder();
- // for (int i = 0; i < elemento.Partes.Count; i++)
- // {
- // strPartes.Append(elemento.Partes[i].Nombre);
- // if (i + 1 < elemento.Partes.Count)
- // {
- // strPartes.Append(", ");
- // }
- // }
- // b.Partes = strPartes.ToString();
- //}
- return lista;
- }
- }
- }
Add Comment
Please, Sign In to add comment