Example #1
0
        public async Task <RespuestaGetAll <PedidoDTO> > GetPedidos(int page, int take)
        {
            try
            {
                var colleccion = (await _context.Pedidos
                                  .Include(x => x.Items)
                                  .OrderByDescending(x => x.Id)
                                  .ToListAsync()).MapTo <IEnumerable <PedidoDTO> >();
                var response = new RespuestaGetAll <PedidoDTO>()
                {
                    Mensaje = new Mensaje {
                        EsError = false, Codigo = "100", Descripcion = "Se consultaron los pedidos correctamente"
                    }
                    ,
                    DataCollection = colleccion
                };

                return(response);
            }
            catch (Exception ex)
            {
                return(new RespuestaGetAll <PedidoDTO>()
                {
                    Mensaje = new Mensaje {
                        EsError = true, Codigo = "101", Descripcion = "Ocurrio un problema al consultar pedidos"
                    },
                });
            }
        }
Example #2
0
        public async Task <RespuestaGetAll <ProductoDto> > GetProductosAsync(int page, int take, IEnumerable <int> productos = null)
        {
            try
            {
                var colleccion = (await _context.Productos.Where(x => productos == null || productos.Contains(x.SKU))
                                  .OrderByDescending(x => x.SKU)
                                  .ToListAsync()).MapTo <IEnumerable <ProductoDto> >();
                var response = new RespuestaGetAll <ProductoDto>()
                {
                    Mensaje = new Mensaje {
                        EsError = false, Codigo = "100", Descripcion = "Se consultaron productos correctamente"
                    }
                    , DataCollection = colleccion
                };

                return(response);
            }
            catch (Exception ex)
            {
                return(new RespuestaGetAll <ProductoDto>()
                {
                    Mensaje = new Mensaje {
                        EsError = true, Codigo = "101", Descripcion = "Ocurrio un problema al consultar productos"
                    },
                });
            }


            //return colleccion.MapTo<List<ProductoDto>>();
        }