// GET: Alumno/Noticias public ActionResult Index() { NoticiasIndexViewModel viewModel = new NoticiasIndexViewModel(); viewModel.Pagina = 1; viewModel.noticias = NoticiaDataAccess.ObtenerNoticia().OrderByDescending(not => not.Fecha).ToList(); viewModel.CalcularPaginacion(viewModel.noticias.Count); viewModel.noticias = viewModel.noticias.Take(viewModel.resultadosPorPagina).ToList(); return(View(viewModel)); }
public ActionResult Index(NoticiasIndexViewModel viewModel) { var GrupoUsuarioID = ((ClaimsIdentity)User.Identity).FindFirst("GrupoUsuario").Value; if (GrupoUsuarioID == "") { viewModel.noticias = NoticiaDataAccess.ObtenerNoticia().OrderByDescending(not => not.Fecha).ToList(); } else { viewModel.noticias = db.NoticiaGrupos.Where(ng => ng.GrupoUsuarioId.ToString() == GrupoUsuarioID) .Select(gu => gu.Noticia).OrderByDescending(not => not.Fecha).ToList(); } viewModel.CalcularPaginacion(viewModel.noticias.Count()); int skip = (viewModel.Pagina - 1) * viewModel.resultadosPorPagina; viewModel.noticias = viewModel.noticias.Skip(skip).Take(viewModel.resultadosPorPagina).ToList(); return(View(viewModel)); }