// GET: Usuarios public ActionResult Index() { var TodasNoticias = Mapper.Map <IEnumerable <Noticia>, IEnumerable <NoticiaViewModel> >(_noticiaApp.GetAll()); var TodosUsuarios = Mapper.Map <IEnumerable <Usuario>, IEnumerable <UsuarioViewModel> >(_usuarioApp.GetAll()); var NoticiasDesativadas = Mapper.Map <IEnumerable <Noticia>, IEnumerable <NoticiaViewModel> >(_noticiaApp.GetAll().Where(x => x.Disponivel = false)); var UsuariosDesativadas = Mapper.Map <IEnumerable <Usuario>, IEnumerable <UsuarioViewModel> >(_usuarioApp.GetAll().Where(x => x.Ativo = false)); var contTotalUsuario = TodosUsuarios.Count(); var contTotalNoticia = TodasNoticias.Count(); var contUsuarioDstv = UsuariosDesativadas.Count(); var contNoticiaDstv = NoticiasDesativadas.Count(); Session["QuantUsu"] = contTotalUsuario; Session["QuantNoti"] = contTotalNoticia; Session["QuantUsuDstv"] = contUsuarioDstv; Session["QuantNotiDstv"] = contNoticiaDstv; return(View()); }
// GET: Usuarios public ActionResult Index() { var TodasNoticias = Mapper.Map <IEnumerable <Noticia>, IEnumerable <NoticiaViewModel> >(_noticiaApp.GetAll().Where(x => x.UsuarioId == Convert.ToInt32(Session["usuarioLogadoID"]))); var NoticiasDesativadas = Mapper.Map <IEnumerable <Noticia>, IEnumerable <NoticiaViewModel> >(_noticiaApp.GetAll().Where(x => x.UsuarioId == Convert.ToInt32(Session["usuarioLogadoID"]) && x.Disponivel == false)); var contTotalNoticia = TodasNoticias.Count(); var contNoticiaDstv = NoticiasDesativadas.Count(); Session["QuantNoti"] = contTotalNoticia; Session["QuantNotiDstv"] = contNoticiaDstv; return(View()); }
// GET: Home public ActionResult Index(string pesquisa, DateTime?startdate, DateTime?enddate) { if (pesquisa == null && !startdate.HasValue && !enddate.HasValue) { var noticiaViewModel = Mapper.Map <IEnumerable <Noticia>, IEnumerable <NoticiaViewModel> >(_noticiaApp.GetAll().OrderByDescending(x => x.DataCadastro)); return(View(noticiaViewModel)); } else { switch (pesquisa == null) { case true: { var noticiaViewModel = Mapper.Map <IEnumerable <Noticia>, IEnumerable <NoticiaViewModel> >(_noticiaApp.GetAll().Where(n => n.DataCadastro.CompareTo(startdate) >= 0 && n.DataCadastro.CompareTo(enddate) <= 0)); return(View(noticiaViewModel)); } break; case false: { var noticiaViewModel = Mapper.Map <IEnumerable <Noticia>, IEnumerable <NoticiaViewModel> >(_noticiaApp.GetAll().Where(n => n.PalavraChave.ToLower() == pesquisa.ToLower().Trim())); return(View(noticiaViewModel)); } break; } } return(View()); }
// GET: Noticias public ActionResult Index() { var noticiaViewModel = Mapper.Map <IEnumerable <Noticia>, IEnumerable <NoticiaViewModel> >(_noticiaApp.GetAll().Where(n => n.Disponivel)); return(View(noticiaViewModel)); }