// GET: AnunciosController public ActionResult Index() { var anuncios = _anuncioApp.GetAll(); var anuncioViewModel = _mapper.Map <IEnumerable <Anuncio>, IEnumerable <AnuncioViewModel> >(anuncios); return(View(anuncioViewModel)); }
// GET: Anuncios public ActionResult Index() { var anuncioViewModel = Enumerable.Empty <AnuncioViewModel>(); if (Session["usuarioLogadoId"] == null) { ViewBag.ClienteLogado = false; anuncioViewModel = Mapper.Map <IEnumerable <Anuncio>, IEnumerable <AnuncioViewModel> >(_anuncioApp.GetAll().OrderByDescending(c => c.Pagamentos.OrderByDescending(a => a.Valor))); } else { int id = Convert.ToInt32(Session["usuarioLogadoId"].ToString()); ViewBag.ClienteLogado = true; anuncioViewModel = Mapper.Map <IEnumerable <Anuncio>, IEnumerable <AnuncioViewModel> >(_anuncioApp.BuscarPorCliente(_clienteApp.GetById(id))); } return(View(anuncioViewModel)); }