public ActionResult homepage(RenderModel model) { var homepage = ContentHelper.GetByNodeId <HomepageDocumentType>(model.Content.Id); var homepageViewModel = new HomepageViewModel(homepage); return(CurrentTemplate(homepageViewModel)); }
public async Task <IActionResult> Index(int page = 1, int?SalaryRange = null, int?Department = null) { var vacancyCrud = new VacancyCrud(); var departmentCrud = new DepartmentCrud(); var salaryRangeCrud = new SalaryRangeCrud(); var departments = await departmentCrud.FindAll(); var salaryRange = await salaryRangeCrud.FindAll(); var vacancies = await vacancyCrud.FindWithFilters(page, SalaryRange, Department); var viewModel = new HomepageViewModel { Department = Department, SalaryRange = SalaryRange, Departments = departments.Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.DepartmentName }).ToList(), SalaryRanges = salaryRange .Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.DisplayValue }).ToList(), Vacancies = vacancies }; return(View(viewModel)); }
public ViewResult Index() { var viewModel = new HomepageViewModel { Homepage = _pageRepo.Pages .Include(p => p.Content) .Single(p => p.Identifier == "homepage"), Genres = _genreRepo.Genres .Where(g => g.VisibleFrontEnd == true) .OrderBy(g => g.Name) .ToList(), Mediums = _mediumRepo.Mediums .Where(g => g.VisibleFrontEnd == true) .OrderBy(g => g.Name) .ToList(), Artists = _artistRepo.Artists .OrderBy(g => g.FirstName) .ToList() }; return(View(viewModel)); }
private void BuildViewModel(Sitecore.Data.Items.Item contextItem) { _hvm = new HomepageViewModel(); _hvm.IsUserLoggedIn = Sitecore.Context.User.IsAuthenticated; var userData = _userDataService.GetUserIdamDataFromCookie(System.Web.HttpContext.Current); if (userData == null) { return; } var unilinkPrisonId = userData.PrisonId?.Length > 2 ? userData.PrisonId.Substring(0, 2).ToLower() : userData.PrisonId?.ToLower(); _hvm.SelfHelpLinkUrl = contextItem["Self Help Link Url Template"].Replace("{prison_id}", unilinkPrisonId); _hvm.ShowQuickLinks = !string.IsNullOrEmpty(_hvm.SelfHelpLinkUrl) && !string.IsNullOrEmpty(userData.PrisonId); var textInfo = CultureInfo.CurrentCulture.TextInfo; _hvm.UserFirstName = textInfo.ToTitleCase(userData.GivenName.ToLower()); }
public ActionResult Homepage(int id = 0) { var model = new HomepageViewModel(id); model.Initialization(); return(PartialView(model)); }
public async void CancelChangesAsync() { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { await HomepageViewModel.LoadProjects(); }); }
public IActionResult Index() { var model = new HomepageViewModel(); model.applicationSettings = _applicationSettings; model.config = _config; return(View("Index", model)); }
public ActionResult Index() { var vm = new HomepageViewModel { IsAuthenticated = User.Identity.IsAuthenticated }; return(View(vm)); }
public IActionResult <HomepageViewModel> Index(HttpSession session, string filter) { filter = WebUtility.UrlDecode(filter); HomepageViewModel model = new HomepageViewModel(); User currentUser = this.securityService.GetCurrentlyLoggedUser(session); if (filter == "Bought Games") { if (currentUser != null && currentUser.Games != null) { model.Email = currentUser.Email; model.Games = currentUser .Games .Select( g => new GameHomePageViewModel { Id = g.Id, Title = g.Title, Price = g.Price, Size = g.Size, Description = g.Description, VideoUrl = g.VideoUrl, Thumbnail = g.ImageThumbnail }); } else { model.Games = new List <GameHomePageViewModel>(); } } else if (string.IsNullOrEmpty(filter) || filter == "All Games") { if (currentUser != null) { model.Email = currentUser.Email; } model.Games = this.gameService.GetAll() .Select( g => new GameHomePageViewModel { Id = g.Id, Title = g.Title, Price = g.Price, Size = g.Size, Description = g.Description, VideoUrl = g.VideoUrl, Thumbnail = g.ImageThumbnail }); } return(this.View(model)); }
public ActionResult Index() { HomepageViewModel model = new HomepageViewModel { Products = _productProvider.GetAllProducts() }; return(View(model)); }
public ActionResult Index() { var viewModel = new HomepageViewModel { PreviewTwitchChannelName = _configService.Get <string>("StreamerChannel"), Domain = HttpContext.Request.Host.Host }; return(View(viewModel)); }
public async void DeleteProjectAsync() { await((App)App.Current).projects.DeleteProjectAsync(SelectedProject); await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { await HomepageViewModel.LoadProjects(); }); }
public IActionResult Index() { HomepageViewModel homepageViewModel = new HomepageViewModel() { Employees = this.employeeService.GetUpcomingBirthdays(), LastProfileAdjustments = this.profileAdjustmentService.GetLastProfileAdjustments(x => x.Include(y => y.Employee)) }; return(View(homepageViewModel)); }
public async Task <IActionResult> Index() { var cat = await _context.Categories.ToListAsync(); var prod = await _context.Products.Include(p => p.Supplier).Include(p => p.Category).Where(p => p.UnitsInStock > 0).ToListAsync(); var homeViewModel = new HomepageViewModel(cat.Select(c => new CategoryViewModel(c)).ToList <ICanShowAsCard>(), prod.Select(p => new ProductViewModel(p, _env.WebRootPath)).ToList()); return(View(homeViewModel)); }
public ActionResult Index() { var trips = db.Trips.ToList(); var viewModel = new HomepageViewModel() { Trips = trips.Select(trip => Mapper.Map<TripViewModel>(trip)) .ToList(), SpecialOffers = new SpecialOffersViewModel() }; return View(viewModel); }
public IActionResult Index() { HomepageViewModel viewModel = new HomepageViewModel { Carousels = _carouselService.GetAllWeb(), UpcomingEvents = _eventService.UpcomingEvents(), Reviews = _reviewService.GetAllWeb(), LastNews = _newsService.LastNewsHomepage() }; return(View(viewModel)); }
public HomepageViewModel BuildHomepageViewModel() { var model = new HomepageViewModel() { SideBar = BuildSidebarContentViewModel() }; model.LastPosts = model.SideBar.LastPosts; model.PostCount = model.LastPosts.Count(); return(model); }
public HomepageViewModel BuildHomepageViewModel(string searchResult) { var result = _postRepository.SearchPosts(searchResult); var model = new HomepageViewModel() { SideBar = BuildSidebarContentViewModel(), LastPosts = BuildListOfPostsViewModel(result), PostCount = result.Count() }; return(model); }
public ActionResult Index() { var products = context.Products.ToList(); var categories = context.Categories.ToList(); var model = new HomepageViewModel { Products = products, Categories = categories }; return(View(model)); }
public ActionResult Index() { var model = new HomepageViewModel { Specials = from s in DataManager.Instance.GetSpecials() select new SpecialsViewModel { Title = s.Title, Description = s.Description }, Featured = DataManager.Instance.GetFeatured() }; return(View(model)); }
public void When_Index_Returns_IndexView() { //Given _homepageModel = new HomepageViewModel(); _postBuilder.Setup(x => x.BuildHomepageViewModel()).Returns(_homepageModel); //When var result = _homeController.Index() as ViewResult; //Then Assert.NotNull(result); Assert.IsInstanceOf <HomepageViewModel>(result.Model); Assert.AreEqual(String.Empty, result.ViewName); }
public void When_Index_with_SearchViewModel_Returns_IndexView() { //Given _homepageModel = new HomepageViewModel(); _postBuilder.Setup(x => x.BuildHomepageViewModel(It.IsAny <string>())).Returns(_homepageModel); var searchModel = new SearchViewModel(); //When var result = _homeController.Index(searchModel) as ViewResult; //Then Assert.NotNull(result); Assert.IsInstanceOf <HomepageViewModel>(result.Model); Assert.AreEqual("Index", result.ViewName); }
public async void SaveChangesAsync() { Project project = ProjectInputModel.ToProject(ProjectInputModel); project.ProjectId = SelectedProject.ProjectId; await((App)App.Current).projects.UpdateAsync(project); await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { SelectedProject = await((App)App.Current).projects.GetAsync(SelectedProject.ProjectId); await HomepageViewModel.LoadProjects(); }); }
public ActionResult Homepage(HomepageViewModel homepageVieModel) { //ViewBag.SelectedCityId = SelectedCityId; //ViewBag.SelectedCountryId = SelectedCountryID; //SelectList selectListCity = new SelectList(City.GetFakeCities(), "CityId", "CityName"); //SelectList selectListCountry = new SelectList(Country.GetFakeCountry(), "CountryId", "CountryName"); //ViewBag.CitiesData = selectListCity; //ViewBag.CountriesData = selectListCountry; homepageVieModel.CitiesData = new SelectList(City.GetFakeCities(), "CityId", "CityName"); homepageVieModel.CountriesData = new SelectList(Country.GetFakeCountry(), "CountryId", "CountryName"); return(View(homepageVieModel)); }
private void DisplayForArea2(List <LocationDto> locations, string area1, string area2, List <HomepageViewModel> items) { if (locations == null || items == null) { return; } List <LocationDto> exists; if (string.IsNullOrEmpty(area1)) { exists = locations.Where(x => x.Area1 == "Hà Nội" && x.Area2 == "Cầu Giấy").ToList(); } else { exists = locations.Where(x => x.Area1 == area1 && x.Area2 == area2).ToList(); } LocationBlo.Sort(exists, SortOption.Rating, false); int count = 0; foreach (var location in exists) { HomepageViewModel hvm = new HomepageViewModel { Id = location.Id, Name = location.Name, Rating = location.Rating, Area1 = location.Area1, Area2 = location.Area2 }; if (location.Specialists.Count > 0) { hvm.Specialist = location.Specialists[0]; } items.Add(hvm); count++; if (count == 15) { break; } } }
public ActionResult Index() { var model = new HomepageViewModel { Heading1 = ctx.Global.AsNoTracking().FirstOrDefault().Heading1Homepage, Heading1Eng = ctx.Global.AsNoTracking().FirstOrDefault().Heading1HomepageEng, Heading2 = ctx.Global.AsNoTracking().FirstOrDefault().Heading2Homepage, Heading2Eng = ctx.Global.AsNoTracking().FirstOrDefault().Heading2HomepageEng, Text = ctx.Global.AsNoTracking().FirstOrDefault().WritingHomepage, TextEng = ctx.Global.AsNoTracking().FirstOrDefault().WritingHomepageEng, MetaDescription = ctx.MetaTags.AsNoTracking().FirstOrDefault().HomeMetaDescription, MetaKeywords = ctx.MetaTags.AsNoTracking().FirstOrDefault().HomeMetaKeywords }; return(View(model)); }
public HomepageViewModel BuildHomepageViewModel(int displayCount) { var lastPosts = _postRepository.GetPosts() .Where(x => x.IsDeleted == false) .OrderByDescending(x => x.PostedAt) .Take(displayCount).ToList(); var model = new HomepageViewModel() { SideBar = BuildSidebarContentViewModel(), LastPosts = BuildListOfPostsViewModel(lastPosts), PostCount = lastPosts.Count() }; return(model); }
private void DisplayForSpecialist(List <LocationDto> locations, string specialist, List <HomepageViewModel> items) { if (locations == null || items == null) { return; } List <LocationDto> exists; if (string.IsNullOrEmpty(specialist)) { exists = locations.Where(x => x.Exists("Chấn thương chỉnh hình")).ToList(); } else { exists = locations.Where(x => x.Exists(specialist)).ToList(); } LocationBlo.Sort(exists, SortOption.Rating, false); int count = 0; foreach (var location in exists) { HomepageViewModel hvm = new HomepageViewModel { Id = location.Id, Name = location.Name, Rating = location.Rating, Area1 = location.Area1, Area2 = location.Area2 }; if (location.Specialists.Count > 0) { hvm.Specialist = location.Specialists[0]; } items.Add(hvm); count++; if (count == 15) { break; } } }
// GET: Home public ActionResult Homepage() { //SelectList selectListCity = new SelectList(City.GetFakeCities(), "CityId", "CityName"); //SelectList selectListCountry = new SelectList(Country.GetFakeCountry(), "CountryId", "CountryName"); //ViewBag.CitiesData = selectListCity; //ViewBag.CountriesData = selectListCountry; HomepageViewModel homepageViewModel = new HomepageViewModel() { CitiesData = new SelectList(City.GetFakeCities(), "CityId", "CityName"), CountriesData = new SelectList(Country.GetFakeCountry(), "CountryId", "CountryName"), SelectedCityId = -1, SelectedCountryId = -1 }; return(View(homepageViewModel)); }
public IActionResult Index() { var viewModel = new HomepageViewModel(); var dogsNotWalkedToday = GetDogsNotWalkedToday(); var topWalkers = GetTopWalkers(); var totalWalkTimeInMinutes = topWalkers.Sum(w => w.TotalDuration); var totalWalkTimeSpan = TimeSpan.FromMinutes(totalWalkTimeInMinutes); var totalWalkDisplay = $"{totalWalkTimeSpan.Hours} Hours {totalWalkTimeSpan.Minutes} Minutes"; viewModel.Dogs = dogsNotWalkedToday; viewModel.Today = DateTime.Now; viewModel.TopWalkers = topWalkers; viewModel.TotalWalkTime = totalWalkDisplay; return(View(viewModel)); }