public ActionResult Index(int pagina = 1) { #region Test //var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(db)); //var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(db)); //roleManager.Create(new IdentityRole("admin")); //var users = userManager.Users.Select(u => u.UserName).ToList(); //var test = db.Mascotas.Include(m => m.TipoDeMascota).ToString(); #endregion var cantidadRegistrosPorPagina = 6; // parámetro using (var db = new ContextModel()) { var personas = db.Mascotas.OrderBy(x => x.Id) .Skip((pagina - 1) * cantidadRegistrosPorPagina) .Take(cantidadRegistrosPorPagina).ToList(); var totalDeRegistros = db.Mascotas.Count(); var modelo = new ViewModels.IndexViewModel(); modelo.Mascotas = personas; modelo.PaginaActual = pagina; modelo.TotalDeRegistros = totalDeRegistros; modelo.RegistrosPorPagina = cantidadRegistrosPorPagina; return(View(modelo)); } }
//Список всех фильмов public ActionResult Index(int page = 1) { int pageSize = 3; IEnumerable <Movie> movies = _context.Movies .Include(m => m.Director) .Include(m => m.Genres) .OrderBy(m => m.Id) .Skip((page - 1) * pageSize) .Take(pageSize) .ToList(); PageInfo pageInfo = new PageInfo { PageNumber = page, PageSize = pageSize, TotalItems = _context.Movies.Count() }; ViewModels.IndexViewModel viewModel = new ViewModels.IndexViewModel { Movies = movies, PageInfo = pageInfo }; return(View(viewModel)); }
public async Task <ActionResult> Index(int?page) { // Disabled feature. //Task.Factory.StartNew(() => //{ // using (ApplicationDbContext db = new ApplicationDbContext()) // { // var latestRanking = db.RankingHistory.OrderByDescending(rh => rh.RankingDateTime).FirstOrDefault(); // if (latestRanking == null || // latestRanking.RankingDateTime.AddDays(ConfigurationHelper.Instance.RankingPersistPeriod) // < DateTime.Now) // { // RankPeopleLists(db); // } // } //}); var postOfTheDay = DbContext.PostsOfTheDay .FirstOrDefault(p => DbFunctions.TruncateTime(p.Date) == DbFunctions.TruncateTime(DateTime.Now)); if (postOfTheDay == null) { var randomPost = DbContext.Posts .OrderBy(p => Guid.NewGuid()) .FirstOrDefault(p => p.Image != null); if (randomPost != null) { var newPostOfTheDay = DbContext.PostsOfTheDay.Create(); newPostOfTheDay.Date = DateTime.Now.Date; newPostOfTheDay.Post = randomPost; postOfTheDay = DbContext.PostsOfTheDay.Add(newPostOfTheDay); await DbContext.SaveChangesAsync(); } } var pageSize = ConfigurationHelper.Instance.PageSize; var posts = DbContext.Posts .OrderByDescending(p => p.DateCreated) .Skip(pageSize * ((page ?? 1) - 1)) .Take(pageSize) .ToList(); var topStatsCount = ConfigurationHelper.Instance.TopStatsCount; var topContributors = DbContext.Users .OrderByDescending(u => u.Posts.Count()) .Take(topStatsCount) .ToList(); var topPosts = DbContext.Posts .OrderByDescending(p => p.Votes.Sum(v => (int)v.Type)) .Take(topStatsCount) .ToList(); var viewModel = new ViewModels.IndexViewModel() { Posts = posts, TopContributors = topContributors, TopPosts = topPosts, PostOfTheDay = postOfTheDay }; return(View(viewModel)); }
// GET: Article public ActionResult Index() { ViewModels.IndexViewModel ivm = new ViewModels.IndexViewModel(); ivm.Accounts = db.Accounts.OrderByDescending(a => a.ID).Skip(0).Take(6).ToList(); //0表示从第0个起 取前10个数据 按照点击量倒序排的序 ivm.Articles = db.Articles.OrderByDescending(a => a.clickCount).Skip(0).Take(10).ToList(); return(View(ivm)); }
public IActionResult Index() { var viewModel = new ViewModels.IndexViewModel { CustomerList = Helpers.Customers.createCustomers("customer") }; return(View()); }
public ActionResult Index() { Session["language"] = "en"; ViewModels.IndexViewModel viewModel = new ViewModels.IndexViewModel(); var banner_set = db.banner.OrderBy(m => m.id).ToList(); viewModel.banner = banner_set; return(View()); }
public void IndexRetrievesTopTenAngryTweets() { HomeController controller = new HomeController(); ViewResult result = controller.Index() as ViewResult; ViewModels.IndexViewModel view_model = (ViewModels.IndexViewModel)result.Model; Assert.IsNotNull(view_model.TopAngryWords); Assert.IsTrue(view_model.TopAngryWords.Count == 10); Assert.IsNotNull(view_model.TopAngryWords.First().Text); }
public void IndexRetrievesFiveRandomTweets() { HomeController controller = new HomeController(); ViewResult result = controller.Index() as ViewResult; ViewModels.IndexViewModel view_model = (ViewModels.IndexViewModel)result.Model; Assert.IsNotNull(view_model.RatableTweets); Assert.IsTrue(view_model.RatableTweets.Count == 5); Assert.IsNotNull(view_model.RatableTweets.First().Text); }
public IActionResult Index() { List <Models.TblMembers> _TblMembers = UnitOfWork.Repository <DevelopersHub.Models.TblMembers>().GetAll().ToList <Models.TblMembers>(); int _Count = _TblMembers.Count(); QueryParameters _queryparameters = new QueryParameters(); _queryparameters.SqlSourceObjectName = "Tbl_Members"; _queryparameters.PageIndex = 0; _queryparameters.PageSize = 11; Microsoft.EntityFrameworkCore.Storage.RelationalDataReader _RelationalDataReader = UnitOfWork.GetResult <DevelopersHub.Models.TblMembers>(_queryparameters); IndexViewModel __indexViewModel = new ViewModels.IndexViewModel(); __indexViewModel.Members = new List <TblMembers>(); while ( _RelationalDataReader.DbDataReader.Read()) { TblMembers tblmembers = new TblMembers(); tblmembers.Fname = _RelationalDataReader.DbDataReader["FName"].ToString(); tblmembers.Sname = _RelationalDataReader.DbDataReader["SName"].ToString(); tblmembers.Id = Convert.ToInt32(_RelationalDataReader.DbDataReader["Id"].ToString()); __indexViewModel.Members.Add(tblmembers); } UnitOfWork.CloseReader(); List <TblProposals> __list_proposals = UnitOfWork.Repository <TblProposals>().GetAll().ToList(); __indexViewModel.Proposals = __list_proposals; foreach (TblProposals item in __indexViewModel.Proposals) { item.M = UnitOfWork.Repository <DevelopersHub.Models.TblMembers>().Get(x => x.Id == item.Id); } ViewModel = __indexViewModel; ViewData["Message"] = "Forums " + _Count.ToString(); return(View(__indexViewModel)); }
// GET: /Peliculas/ public ActionResult Index() { var viewModel = new ViewModels.IndexViewModel { TvNiños = Datos.tvniños, Drama = Datos.drama, AccionyAventuras = Datos.accionyaventuras, MiLista = Datos.miLista, ContinuarViendo = Datos.continuarViendo }; return(View(viewModel)); }
public ActionResult Filter(string filter) { if (filter.ToLower() == "all") { return(RedirectToAction("Index")); } var mascotas = db.Mascotas.Include(m => m.TipoDeMascota).Where(s => s.TipoDeMascota.Name == filter).ToList(); var totalDeRegistros = mascotas.Count(); var modelo = new ViewModels.IndexViewModel(); modelo.Mascotas = mascotas; modelo.PaginaActual = 1; modelo.TotalDeRegistros = totalDeRegistros; modelo.RegistrosPorPagina = 6; return(View("Index", modelo)); }
public ActionResult FindBy(string generos = "all") { var array = generos.Split('/'); var result = new List <Mascota>(); if (generos == "all") { var all = db.Mascotas.Include(m => m.TipoDeMascota).ToList(); result.AddRange(all); } for (int i = 0; i < array.Length; i++) { string type = array[i].ToString(); if (type.ToLower() == "dog") { var dog = db.Mascotas.Include(m => m.TipoDeMascota).Where(s => s.TipoDeMascota.Name == type).ToList(); result.AddRange(dog); } if (type.ToLower() == "cat") { var cat = db.Mascotas.Include(m => m.TipoDeMascota).Where(s => s.TipoDeMascota.Name == type).ToList(); result.AddRange(cat); } if (type.ToLower() == "ave") { var ave = db.Mascotas.Include(m => m.TipoDeMascota).Where(s => s.TipoDeMascota.Name == type).ToList(); result.AddRange(ave); } } var totalDeRegistros = result.Count(); var modelo = new ViewModels.IndexViewModel(); modelo.Mascotas = result; modelo.PaginaActual = 1; modelo.TotalDeRegistros = totalDeRegistros; modelo.RegistrosPorPagina = 6; return(View(modelo)); }
public ActionResult Index() { var result = this.Data.Categories.Include("Books").ToList() .Select(x => new TreeViewItemModel { Text = x.Name, Items = x.Books.Select(y => new TreeViewItemModel { Text = y.Title }) .ToList() }); ViewModels.IndexViewModel homeVm = new ViewModels.IndexViewModel() { TreeViewItems = result, Books = Data.Books.Select(BookViewModel.FromBook) }; return(View(homeVm)); }
// GET api/<controller> public IEnumerable <object> Get() { using (var context = new SistemaAcademico.DataModel.AcademicSystemContext()) { ViewModels.IndexViewModel Model = new ViewModels.IndexViewModel(); List <MenuOptionsDTO> MenuResults = new List <MenuOptionsDTO>(); var source = context.OpcionesDelMenu.Where(o => o.parent == null).OrderBy(o => o.order).ToList(); foreach (MenuOption Opcion in source) { MenuResults.Add(new MenuOptionsDTO { OpcionDeMenu = Opcion, Childs = context.OpcionesDelMenu .Where(child => child.parent.id == Opcion.id) .OrderBy(o => o.order) .ToList() }); } return(MenuResults); } }
public ActionResult Index() { var result = this.Data.Categories.Include("Books").ToList() .Select(x => new TreeViewItemModel { Text = x.Name, Items = x.Books.Select(y => new TreeViewItemModel { Text = y.Title }) .ToList() }); ViewModels.IndexViewModel homeVm = new ViewModels.IndexViewModel() { TreeViewItems = result, Books = Data.Books.Select(BookViewModel.FromBook) }; return View(homeVm); }
public ActionResult Index() { string identity = null; string userName = System.Threading.Thread.CurrentPrincipal.Identity.Name; try { identity = Request.Cookies["appUser"].Value; } catch (Exception) { return(View("~/Views/Login/Index.cshtml")); }; using (var context = new SistemaAcademico.DataModel.AcademicSystemContext()) { ViewModels.IndexViewModel Model = new ViewModels.IndexViewModel(); List <MenuOptionsDTO> MenuResults = new List <MenuOptionsDTO>(); var curser_email = identity.Split(',')[0]; var currentUser = context.Usuarios.Where(u => u.Email == curser_email).FirstOrDefault(); var source = context.OpcionesDelMenu .Where(o => o.parent == null && o.allowedType == currentUser.UserType) .OrderBy(o => o.order) .ToList(); foreach (MenuOption Opcion in source) { MenuResults.Add(new MenuOptionsDTO { OpcionDeMenu = Opcion, Childs = context.OpcionesDelMenu .Where(child => child.parent.id == Opcion.id) .OrderBy(o => o.order) .ToList() }); } Model.OpcionesDeMenu = MenuResults; return(View(Model)); } }
public ActionResult LettersList(ViewModels.IndexViewModel IndexViewModel) { WebClient objclient = new WebClient(); string response = null; XmlDocument xdoc = new XmlDocument(); List <LettersListViewModel> emailsList = new List <LettersListViewModel>(); objclient.Credentials = new NetworkCredential(IndexViewModel.Login, IndexViewModel.Password); response = Encoding.UTF8.GetString(objclient.DownloadData("https://mail.google.com/mail/feed/atom")); //"https://www.googleapis.com/gmail/v1/users/"+ IndexViewModel.Login +"/labels" response = response.Replace("<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\">", "<feed>"); xdoc.LoadXml(response); foreach (XmlNode node1 in xdoc.SelectNodes("feed/entry")) { LettersListViewModel email = new LettersListViewModel { From = node1.SelectSingleNode("author/email").InnerText, Title = node1.SelectSingleNode("title").InnerText, Summary = node1.SelectSingleNode("summary").InnerText }; emailsList.Add(email); } return(View(emailsList)); }
protected override void OnInitialized() { this.vm = new ViewModels.IndexViewModel(); }
public ActionResult Index() { ViewModels.IndexViewModel IndexViewModel = new ViewModels.IndexViewModel(); return(View()); }