public IActionResult Products(string searchString, string brand, string category, string sort, int pageIndex = 1, int pageSize = 6) { HomeIndexVm ProductsVM = _productService.GetProductListVm(searchString, brand, category, sort, pageIndex, pageSize); ViewBag.pageSize = pageSize; return(View(ProductsVM)); }
public IActionResult Index() { var vm = new HomeIndexVm(); vm.Teachers = _schoolContext.Teachers; return(View(vm)); }
public async Task <IActionResult> Index() { string userName = HttpContext.Session.GetString("Username"); if (userName == null) { return(new RedirectToActionResult("Login", "Account", null)); } var vm = new HomeIndexVm { Username = userName }; var allPokemonWithTypes = await pokemonContext.Set <PokemonType>() .Include(pt => pt.Pokemon) //join .ThenInclude(p => p.PokemonTypes) .Include(pt => pt.Type) //join .ThenInclude(t => t.PokemonTypes) .ToListAsync(); vm.AllPokemonWithTypeInfo = allPokemonWithTypes.Select(pt => pt.Pokemon); vm.AllCaughtPokemon = await getAllCaught(userName); return(View(vm)); }
/* [Route("ByBrewery/{id}")]*/ public async Task <IActionResult> FindByBrewery(long?id) { Brouwerij brouwer = new Brouwerij(); if (id != null) { brouwer = context.Brouwerijen.Find(id); } if (brouwer != null && id != null) { var bierenVanBrouwer = await context.Beers.Where(bier => bier.Brouwerij.Id == id) .Include(smaak => smaak.Flavors) .ThenInclude(a => a.Flavor) .ToListAsync(); var viewM = new HomeIndexVm { Beers = bierenVanBrouwer, Title = $"Bieren van brouwer {brouwer.Name}" }; return(View("Index", viewM)); } else { var vm = new HomeIndexVm { Beers = null }; return(View("Index", vm)); } }
public ActionResult Index() { ViewBag.Keywords = "новини, київські новини, статті, події, аналітика, афіша Києва, сервіси"; ViewBag.Description = "Моє Місто - це цікаві новини про Київ і афіша цікавих подій у Києві. Інтернет-сайт новин про головні київські новини і те, куди піти в Києві на вихідних. Читати столичні новини варто тут!"; var model = new HomeIndexVm { TopNews = Mapper.Map <List <ArticleBaseVm> >(_context.GetTopNews()), LastNews = Mapper.Map <List <ArticleBaseVm> >(_context.GetLastNews()), InterestedEvents = Mapper.Map <List <EventBaseVm> >(_context.GetInterestedEvents()), LastTravels = Mapper.Map <List <ArticleBaseVm> >(_context.GetTopTravels()), }; var places = _context.GetPlaceInfo(model.InterestedEvents.Select(s => s.EventId).ToList()); Parallel.ForEach(model.InterestedEvents, eventItem => { if (places.ContainsKey(eventItem.EventId)) { eventItem.PlaceUrl = places[eventItem.EventId].Item1; eventItem.PlaceName = places[eventItem.EventId].Item2; } }); return(View(model)); }
public IActionResult Index() { var model = new HomeIndexVm(); model.Beers = _context.Beers.Include(x => x.User).Where(x => x.User != null).ToList(); return(View(model)); }
public IActionResult Index() { var model = new HomeIndexVm(); model.Restaurants = _restaurantData.GetAll(); model.CurrentMessage = _gretter.GetMessageOfTheDay(); return(View(model)); }
// GET: Home public ActionResult Index() { var vm = new HomeIndexVm(); vm.Leagues = new LeagueManager().GetAllLeagues().OrderBy(l => l.Name).ToList(); vm.Teams = new TeamManager().GetAllTeams().OrderBy(t => t.Name).ToList(); return(View(vm)); }
public ActionResult Index() { var articles = db.Articles.Include(a => a.Type) .OrderByDescending(a => a.Id).Take(6).ToList(); var vm = new HomeIndexVm { Articles = articles }; return(View(vm)); }
public async Task <IActionResult> Index() { HomeIndexVm indexvm = new HomeIndexVm(); indexvm.Beers = await context.Beers .Include(b => b.Flavors) .ThenInclude(fl => fl.Flavor) .OrderBy(e => e.Name) .ToListAsync(); return(View(indexvm)); }
public async Task <IActionResult> Index() { var products = await _productsService.AllWithoutDeletedAsync(); var productsArr = products.ToArray(); var model = new HomeIndexVm { NewItems = productsArr.Take(5), OnSaleItems = productsArr.Skip(3).Take(3), TopSellingItems = productsArr.Skip(6).Take(3) }; return(View(model)); }
public async Task <IActionResult> FindByFlavor(long id) { var flavor = await context.Flavors .Include(f => f.BeersWithFlavor) .ThenInclude(bfl => bfl.Beer) .ThenInclude(b => b.Flavors) .ThenInclude(bf => bf.Flavor) .FirstOrDefaultAsync(f => f.Id == id); HomeIndexVm indexvm = new HomeIndexVm { Beers = flavor.BeersWithFlavor.Select(fl => fl.Beer), Title = $"Beer with \"{flavor.Name}\" flavor" }; return(View("Index", indexvm)); }
public async Task <IActionResult> Index() { HomeIndexVm vm = new HomeIndexVm(); //will be passed to Index View //1. get teacher with Id == 1 long teachId = 1; vm.TeacherWidthIdOne = await schoolContext.Teachers.FindAsync(teachId); //2. get students born before 2000, ordered by Name vm.StudentsBornBefore2k = await schoolContext.Students .Where(s => s.Birthdate.Year < 2000) .OrderBy(s => s.Name) .ToListAsync(); //3. get total amount of scholarships vm.TotalScholarships = await schoolContext.Students .SumAsync(s => s.Scholarship) ?? 0; //return 0 if null //4. get scholarship student with studentinfo loaded // order by scholarship, then by name vm.ScholarshipStudentsWithInfo = await schoolContext.Students .Include(s => s.ContactInfo) .Where(s => s.Scholarship != null) .OrderBy(s => s.Scholarship) .ThenBy(s => s.Name) .ToListAsync(); //5. get a full graph of all courses // order by the amount of student in course, descending var allStudentCourses = await schoolContext.Set <StudentCourse>() //start in the join table .Include(sc => sc.Course) .ThenInclude(c => c.Lecturer) .Include(sc => sc.Student) .ThenInclude(s => s.ContactInfo) .ToListAsync(); //operations beyond this point happen in memory, not in database vm.Courses = allStudentCourses .Select(sc => sc.Course) //select by Course, once results are in .Distinct() //select each course only once .OrderByDescending(sc => sc.StudentCourses.Count); //order by number of StudentCourses return(View(vm)); }
public async Task <IActionResult> Index() { _logger.Log(LogLevel.Information, "Home: Index entered"); var vm = new HomeIndexVm { CardCount = _configuration.GetValue <int>("DashboardCardCount"), Stacks = new List <DashboardStack>(), Projects = await _projectsApi.GetProjectsAsync() }; var coloumns = new Dictionary <BugStatus, string> { { BugStatus.Open, "Open" }, { BugStatus.Assigned, "In Progress" }, { BugStatus.Resolved, "Resolved" }, { BugStatus.Closed, "Closed" } }; var BugsList = await _bugsApi.GetBugsAsync(); foreach (var pair in coloumns) { var stack = new DashboardStack { AssociatedStatus = pair.Key, Title = pair.Value }; // Sort Open & In Progress by oldest, resolved & closed by newest var bugs = ((pair.Key == BugStatus.Open) || (pair.Key == BugStatus.Assigned)) ? BugsList.Where(b => b.Status.HasFlag(pair.Key)).OrderBy(b => b.DateSubmitted) : BugsList.Where(b => b.Status.HasFlag(pair.Key)).OrderByDescending(b => b.DateSubmitted); stack.Count = bugs.Count(); stack.Bugs = bugs.Take(vm.CardCount).ToList(); vm.Stacks.Add(stack); } return(View(vm)); }
public IActionResult Index() { //declaratie ViewModel var viewModel = new HomeIndexVm(); //fill the model foreach (var movie in movieRepository.GetMovies()) { viewModel.Movies.Add ( new HomeShowMovieVM { Movie = movie, ShowBackButton = false } ); } //pass the model to the view return(View(viewModel)); }
public IActionResult Index() { var vm = new HomeIndexVm(); vm.Products = _herhalingContext.Products.Include(p => p.ProductInfo); var UserName = HttpContext.Session.GetString("Name"); if (UserName != null) { var user = _herhalingContext.Users.FirstOrDefault(u => u.Name == UserName); if (user.UserProducts == null) { user.UserProducts = new List <Product> { }; _herhalingContext.SaveChanges(); } vm.User = user; } return(View(vm)); }
public IActionResult Index() { NorthwndContext ctx = new NorthwndContext(); //select ProductID,ProductName.... from Products //List<Product> products= ctx.Products.ToList(); //------------------------------------------- HomeIndexVm vm = new HomeIndexVm(); vm.Products = ctx.Products .Include(prd => prd.Category) .Include(prd => prd.Supplier) .ToList(); vm.Categories = ctx.Categories.Select(cat => new SelectListItem() { Text = cat.CategoryName, Value = cat.CategoryID.ToString() }).ToList(); vm.Categories.Insert(0, new SelectListItem() { Text = "Seçiniz...", Value = "-1" }); vm.Suppliers = ctx.Suppliers.Select(sup => new SelectListItem() { Text = sup.CompanyName, Value = sup.SupplierID.ToString() }).ToList(); vm.Suppliers.Insert(0, new SelectListItem() { Text = "Seçiniz...", Value = "-1" }); return(View(vm)); }
public ActionResult Index() { var myId = User.Identity.GetUserId(); var myFriends = _unitOfWork.FriendRepository .GetAllWithRelatedData(myId); // getting posts of ur friends var posts = _unitOfWork.FriendRepository .GetFriendsPosts(myId, myFriends); // adding ur posts var me = _unitOfWork.UserRepository.Get(myId); posts.AddRange(me.Posts); var viewModel = new HomeIndexVm { User = _unitOfWork.UserRepository.GetWithRelatedData(myId), Posts = posts.OrderByDescending(p => p.Id).ToList() }; return(View(viewModel)); }
public IActionResult Index() { HomeIndexVm ProductIndexVM = _productService.GetProductIndex(8); return(View(ProductIndexVM)); }