public async Task <ActionResult <PeliculasIndexDTO> > Get()
        {
            var Top = 5;
            var Hoy = DateTime.Today;

            var proximosEstrenos = await Context.Peliculas
                                   .Where(x => x.FechaEstreno > Hoy)
                                   .OrderBy(x => x.FechaEstreno)
                                   .Take(Top)
                                   .ToListAsync();

            var enCines = await Context.Peliculas
                          .Where(x => x.EnCines)
                          .Take(Top)
                          .ToListAsync();


            var resultado = new PeliculasIndexDTO();

            resultado.FuturosEstrenos = Mapper.Map <List <PeliculaDTO> >(proximosEstrenos);
            resultado.EnCines         = Mapper.Map <List <PeliculaDTO> >(enCines);
            return(resultado);

            //  var peliculas = await Context.Peliculas.ToListAsync();

            // return Mapper.Map<List<PeliculaDTO>>(peliculas);
        }
Beispiel #2
0
        public async Task <ActionResult <PeliculasIndexDTO> > Get()
        {
            var top = 5;
            var hoy = DateTime.Now;

            var proximosEstrenos = await _applicationDbContext.Peliculas
                                   .Where(x => x.FechaEstreno > hoy)
                                   .OrderBy(x => x.FechaEstreno)
                                   .Take(top)
                                   .ToListAsync();



            var enCines = await _applicationDbContext.Peliculas
                          .Where(x => x.EnCines)
                          .Take(top)
                          .ToListAsync();



            var resultado = new PeliculasIndexDTO();

            resultado.FuturosEstrenos = _mapper.Map <List <PeliculaDTO> >(proximosEstrenos);
            resultado.EnCines         = _mapper.Map <List <PeliculaDTO> >(enCines);


            return(resultado);
        }
Beispiel #3
0
        public async Task <ActionResult <PeliculasIndexDTO> > Get()
        {
            var top = 5;
            var hoy = DateTime.Today;

            var proximosEstrenos = await this.context.Peliculas
                                   .Where(x => x.fechaEstreno > hoy)
                                   .OrderBy(x => x.fechaEstreno)
                                   .Take(top)
                                   .ToListAsync();

            var encines = await this.context.Peliculas
                          .Where(x => x.enCines)
                          .Take(top)
                          .ToListAsync();

            var resultado = new PeliculasIndexDTO();

            resultado.futurosEstrenos = mapper.Map <List <PeliculaDTO> >(proximosEstrenos);
            resultado.encines         = mapper.Map <List <PeliculaDTO> >(encines);

            return(resultado);
        }
Beispiel #4
0
        public async Task <ActionResult <PeliculasIndexDTO> > Get()
        {
            var top = 5;
            var hoy = DateTime.Today;

            var proximosEstrenos = await context.Peliculas
                                   .Where(p => p.FechaEstreno > hoy)
                                   .OrderBy(p => p.FechaEstreno)
                                   .Take(top)
                                   .ToListAsync();

            var enCines = await context.Peliculas
                          .Where(p => p.EnCines)
                          .Take(top)
                          .ToListAsync();

            var resultado = new PeliculasIndexDTO
            {
                EnCines         = mapper.Map <List <PeliculaDTO> >(enCines),
                FuturosEstrenos = mapper.Map <List <PeliculaDTO> >(proximosEstrenos)
            };

            return(resultado);
        }