Example #1
0
        public PagedListResponse <Dtos.PautaItem> GetItemsByFilter(Dtos.Filters.FilterPautaItems filter)
        {
            var pautaId = filter.PautaId.HasValue ? filter.PautaId.Value : PdmContext.Pautas.Single(e => string.Equals(e.Codigo, filter.PautaCodigo)).Id;

            var query = PdmContext
                        .PautasItem.Include(p => p.Tarifa)
                        .Where(t => t.Pauta.Id == pautaId && t.Pauta.Campania.Codigo == filter.CampaniaCodigo)
                        .OrderBy(t => t.CodigoPrograma)
                        .AsQueryable();

            return(new PagedListResponse <Dtos.PautaItem>
            {
                Count = query.Count(),
                Data = Mapper.Map <IList <Entities.PautaItem>, IList <Dtos.PautaItem> >(query.Skip(filter.PageSize * (filter.CurrentPage - 1)).Take(filter.PageSize).ToList())
            });
        }
Example #2
0
        public PagedListResponse <Dtos.PautaDetail> GetPautasByFilter(Dtos.Filters.FilterPautaItems filter)
        {
            var query = PdmContext
                        .Pautas.Include(e => e.Campania)
                        .Where(e => e.Estado == EstadoPauta.Aprobada || e.Estado == EstadoPauta.Cerrada || e.Estado == EstadoPauta.Pendiente)
                        .OrderBy(t => t.Campania.Nombre)
                        .AsQueryable();

            if (filter.CampaniaCodigo > 0)
            {
                query = query.Where(e => e.Campania.Codigo == filter.CampaniaCodigo).AsQueryable();
            }

            return(new PagedListResponse <Dtos.PautaDetail>
            {
                Count = query.Count(),
                Data = Mapper.Map <IList <Entities.Pauta>, IList <Dtos.PautaDetail> >(query.Skip(filter.PageSize * (filter.CurrentPage - 1)).Take(filter.PageSize).ToList())
            });
        }