/// <summary> /// /// </summary> /// <param name="expr"></param> /// <param name="parameters"></param> /// <param name="page"></param> /// <param name="includeHist">0 = without Hist; 1 = with Hist; 2 = only Hist</param> /// <param name="context"></param> /// <returns></returns> public virtual IEnumerable <CatalogoModel> GetCatalogos(QueryExpresion expr, Dictionary <string, object> parameters, long?page, byte includeHist, bool limitarStrings, HttpContextBase context) { SeriesDataService ds = new SeriesDataService(); IEnumerable <SerieModel> seriesList = ds.ObtenerSeries(null, null, context); List <CatalogoModel> read = new List <CatalogoModel>(); switch (includeHist) { case 0: //sin hist read = this.GetOrCreateValue <List <CatalogoModel> >( this.GetOrCreateKey(context), () => this.FillCatalogoList(DataConnection.Instance.ExecuteQuery( string.Format(SqlResource.SqlCatalogoResource, expr?.ToString() ?? "1=1"), parameters, context, page.GetValueOrDefault(1)), seriesList, limitarStrings) , "GetCatalogos", 0, expr?.ToString(), parameters, page.GetValueOrDefault(1) ); break; case 1: //ambos read = this.GetOrCreateValue( this.GetOrCreateKey(context), () => this.FillCatalogoList(DataConnection.Instance.ExecuteQuery( string.Format(SqlResource.SqlCatalogoAmbosResource, expr?.ToString() ?? "1=1"), parameters, context, page.GetValueOrDefault(1)), seriesList, limitarStrings) , "GetCatalogos", 1, expr?.ToString(), parameters, page.GetValueOrDefault(1) ); break; case 2: //solo hist read = this.GetOrCreateValue <List <HistCatalogoModel> >( this.GetOrCreateKey(context), () => this.FillHistCatalogoList(DataConnection.Instance.ExecuteQuery(string.Format(SqlResource.SqlHistCatalogoResource, expr?.ToString() ?? "1=1"), parameters, context, page.GetValueOrDefault(1)), seriesList, limitarStrings) , "GetCatalogos", 2, expr?.ToString(), parameters, page.GetValueOrDefault(1) ).Cast <CatalogoModel>().ToList(); break; } return(read); }
public virtual CatalogoModel GetCatalogo(QueryExpresion expr, Dictionary <string, object> parameters, bool paraEditar, byte includeHist, HttpContextBase context) { SeriesDataService ds = new SeriesDataService(); var seriesList = ds.ObtenerSeries(null, null, context); IDataReader read; switch (includeHist) { case 0: //sin hist read = DataConnection.Instance.ExecuteQuery( string.Format(SqlResource.SqlCatalogoResource, expr?.ToString() ?? "1=1"), parameters, context, 0); if (read.Read()) { CatalogoModel nc = new CatalogoModel(); nc.Fill(read); if (seriesList.Count() > 0) { nc.SeriesNombre = seriesList.FirstOrDefault(sm => sm.ID == nc.IdSerie.GetValueOrDefault(0))?.Nombre; } nc.EstablecerSignaturaPorDefecto(); nc.ListaMaterias = !paraEditar?this.ObtenerMateriasDeCatalogo(nc.ID, context) : null; nc.ListaMateriasSeleccionables = paraEditar ? this.ObtenerMateriasSeleccionablesDeCatalogo(nc.ID, context) : null; nc.ListaLugares = this.ObtenerLugaresDeCatalogo(nc.ID, context); nc.Origen = 0; return(nc); } break; case 1: read = DataConnection.Instance.ExecuteQuery( string.Format(SqlResource.SqlCatalogoAmbosResource, expr?.ToString() ?? "1=1"), parameters, context, 0); if (read.Read()) { int origen = (int)read.GetInt64(read.GetOrdinal("Hist")); CatalogoModel nc = new CatalogoModel(); nc.Fill(read); if (seriesList.Count() > 0) { nc.SeriesNombre = seriesList.FirstOrDefault(sm => sm.ID == nc.IdSerie.GetValueOrDefault(0))?.Nombre; } nc.EstablecerSignaturaPorDefecto(); nc.Origen = origen == 0 ? (byte)0 : (byte)2; if (origen == 0) { nc.ListaMaterias = !paraEditar?this.ObtenerMateriasDeCatalogo(nc.ID, context) : null; nc.ListaMateriasSeleccionables = paraEditar ? this.ObtenerMateriasSeleccionablesDeCatalogo(nc.ID, context) : null; nc.ListaLugares = this.ObtenerLugaresDeCatalogo(nc.ID, context); } return(nc); } break; case 2: //solo hist read = DataConnection.Instance.ExecuteQuery( string.Format(SqlResource.SqlHistCatalogoResource, expr?.ToString() ?? "1=1"), parameters, context, 0); if (read.Read()) { HistCatalogoModel nc = new HistCatalogoModel(); nc.Fill(read); if (seriesList.Count() > 0) { nc.SeriesNombre = seriesList.FirstOrDefault(sm => sm.ID == nc.IdSerie.GetValueOrDefault(0))?.Nombre; } if (string.IsNullOrEmpty(nc.Signatura)) { nc.EstablecerSignaturaPorDefecto(); } return(nc); } break; } return(null); }