42 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
		
		
			
		
	
	
			42 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
|  | namespace GestionIntegral.Api.Dtos.Reportes.ViewModels | ||
|  | { | ||
|  |     // Clases internas para la agrupación | ||
|  |     public class GrupoPublicacion | ||
|  |     { | ||
|  |         public string NombrePublicacion { get; set; } = string.Empty; | ||
|  |         public IEnumerable<DistribucionSuscripcionDto> Suscripciones { get; set; } = Enumerable.Empty<DistribucionSuscripcionDto>(); | ||
|  |     } | ||
|  | 
 | ||
|  |     public class GrupoEmpresa | ||
|  |     { | ||
|  |         public string NombreEmpresa { get; set; } = string.Empty; | ||
|  |         public IEnumerable<GrupoPublicacion> Publicaciones { get; set; } = Enumerable.Empty<GrupoPublicacion>(); | ||
|  |     } | ||
|  | 
 | ||
|  |     public class DistribucionSuscripcionesViewModel | ||
|  |     { | ||
|  |         public IEnumerable<GrupoEmpresa> DatosAgrupados { get; } | ||
|  |         public string FechaDesde { get; set; } = string.Empty; | ||
|  |         public string FechaHasta { get; set; } = string.Empty; | ||
|  |         public string FechaGeneracion { get; set; } = string.Empty; | ||
|  | 
 | ||
|  |         public DistribucionSuscripcionesViewModel(IEnumerable<DistribucionSuscripcionDto> suscripciones) | ||
|  |         { | ||
|  |             DatosAgrupados = suscripciones | ||
|  |                 .GroupBy(s => s.NombreEmpresa) | ||
|  |                 .Select(gEmpresa => new GrupoEmpresa | ||
|  |                 { | ||
|  |                     NombreEmpresa = gEmpresa.Key, | ||
|  |                     Publicaciones = gEmpresa | ||
|  |                         .GroupBy(s => s.NombrePublicacion) | ||
|  |                         .Select(gPub => new GrupoPublicacion | ||
|  |                         { | ||
|  |                             NombrePublicacion = gPub.Key, | ||
|  |                             Suscripciones = gPub.OrderBy(s => s.NombreSuscriptor).ToList() | ||
|  |                         }) | ||
|  |                         .OrderBy(p => p.NombrePublicacion) | ||
|  |                 }) | ||
|  |                 .OrderBy(e => e.NombreEmpresa); | ||
|  |         } | ||
|  |     } | ||
|  | } |