Пример #1
0
 public IActionResult Listar(int quantidade, int limiteIdSuperior, int limiteIdInferior)
 {
     try
     {
         return(ResultadoComRetorno <List <ViewNoticia> >(_servico.Listar(quantidade, limiteIdSuperior, limiteIdInferior)));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
Пример #2
0
        public Retorno ListarFeed(int quantidade = 0, int limiteIdSuperior = 0, int limiteIdInferior = 0)
        {
            try
            {
                var retornoNoticias     = _noticiaServico.Listar(quantidade, limiteIdInferior, limiteIdSuperior);
                var retornoNotificacoes = _notificacaoServico.ObterListaPorUsuario(quantidade, limiteIdSuperior, limiteIdInferior);
                var feed = new List <ViewFeed>();

                if (retornoNoticias.Sucesso)
                {
                    var noticias = retornoNoticias.ObterDados <List <ViewNoticia> >();

                    if (noticias != null)
                    {
                        noticias.ForEach(x => feed.Add((ViewFeed)x));
                    }
                }

                if (retornoNotificacoes.Sucesso)
                {
                    var notificacoes = retornoNoticias.ObterDados <List <ViewNotificacao> >();

                    if (notificacoes != null)
                    {
                        notificacoes.ForEach(x => feed.Add((ViewFeed)x));
                    }
                }

                feed = feed.OrderByDescending(x => x.DataHora).ToList();

                return(Sucesso(feed));
            }
            catch (Exception ex)
            {
                return(Erro(ex));
            }
        }