public News() { this.InitializeComponent(); Application.Current.Resources["SystemControlHighlightListAccentLowBrush"] = new SolidColorBrush(Colors.Transparent); // Убираем ебучую тематическую подсветку с нажатой кнопки Application.Current.Resources["SystemControlHighlightListAccentMediumBrush"] = new SolidColorBrush(Colors.Transparent); ViewModel = new NewsPageViewModel(); }
public ActionResult Index(int?id) { if (id == null) { return(RedirectToAction("Index", "Error")); } NewsViewModel news; try { news = Mapper.ToView(newsService.GetEntityById(id.Value)); } catch (Exception) { return(RedirectToAction("Index", "Error")); } var page = new NewsPageViewModel { News = news, Author = Mapper.ToView(DependencyResolver.Current.GetService <IUserService>().GetEntityById(news.CreatorId)), Comments = ModelHelper.ReadCommentsForModel("News", id.Value) }; return(View(page)); }
public IActionResult Index() { var viewmodel = new NewsPageViewModel(); var contentEntity = this.InstanceRepository.ContentNewsRepository.GetAll().OrderByDescending(x => x.Language == this.SiteLanguage).FirstOrDefault(); viewmodel.ContentNews = Mapper.ToModel(contentEntity); var newsEntities = this.InstanceRepository.NewsRepository.GetAll() .Include("NewsLanguages.NewsLanguageImages").ToList(); viewmodel.Newses = newsEntities.Select(x => { var n = Mapper.ToModel(x); if (n != null) { n.NewsLanguages = x?.NewsLanguages.Select(k => { var nl = Mapper.ToModel(k); if (nl != null) { nl.NewsLanguageImages = k?.NewsLanguageImages.Select(Mapper.ToModel).ToList(); } return(nl); }).ToList(); } return(n); }).ToList(); ViewBag.Tab = "news"; return(View(viewmodel)); }
public IActionResult All(string category, int page = 1) { string req = this.Request.Headers["User-Agent"].ToString(); if (IsMobile(req)) { var viewModel = new NewsPageViewModel(); var news = this.newsService.GetAll <NewsViewModel>(category, ItemsPerPage, (page - 1) * ItemsPerPage); var count = this.newsService.GetCountByCategory(category); viewModel.PagesCount = (int)Math.Ceiling((double)count / ItemsPerPage); viewModel.CurrentPage = page; viewModel.News = news; viewModel.Category = category; return(View("All.mobile", viewModel)); } else { var viewModel = new NewsPageViewModel(); var news = this.newsService.GetAll <NewsViewModel>(category, ItemsPerPage, (page - 1) * ItemsPerPage); var count = this.newsService.GetCountByCategory(category); viewModel.PagesCount = (int)Math.Ceiling((double)count / ItemsPerPage); viewModel.CurrentPage = page; viewModel.News = news; viewModel.Category = category; return(this.View(viewModel)); } }
public static NewsPageViewModel Create(NewsPage currentPage) { var model = new NewsPageViewModel(currentPage); PageViewModelBuilder.SetBaseProperties(model); model.RelatedNews = SearchManager.Instance.FindSimular(currentPage, 0, 5); return model; }
public NewsPage(int id) { vm = new NewsPageViewModel(id); BindingContext = vm; InitializeComponent(); webView.Navigating += (s, e) => { if (e.Url.StartsWith("file:")) { try { var result = Regex.Matches(e.Url, @"(\/[a-z0-9]+)"); string extractedText = ""; foreach (var item in result) { extractedText += item.ToString(); } var uri = new Uri("https://www.aims.org.au" + extractedText); Device.OpenUri(uri); } catch (Exception ex) { Log.Error("myapp", ex.ToString()); } } else if (e.Url.StartsWith("mailto:")) { try { var uri = new Uri(e.Url); Device.OpenUri(uri); } catch (Exception ex) { Log.Error("myapp", ex.ToString()); } } else if (e.Url.StartsWith("http")) { try { var uri = new Uri(e.Url); Device.OpenUri(uri); } catch (Exception ex) { Log.Error("myapp", ex.ToString()); } } e.Cancel = true; }; }
public ActionResult RenderArticleBoxes(NewsPageViewModel model) { SetCulture(model.CurrentPageCulture); //TempData[TempDataVariables.NewsRegionFiltr] = model.SelectedRegionId; //TempData[TempDataVariables.NewsTypeFiltr] = model.NewsTypeFilter.Where(q => q.IsChecked).Select(q => q.Id).ToList(); var _model = _newsService.GetNewsBoxesModel(model); return(PartialView("NewsPartial", _model)); }
public static NewsPageViewModel Create(NewsPage currentPage) { var model = new NewsPageViewModel(currentPage); PageViewModelBuilder.SetBaseProperties(model); model.RelatedNews = SearchManager.Instance.FindSimular(currentPage, 0, 5); return(model); }
public virtual ActionResult GameNews() { INewsPostRepository repo = new EFNewsPostRepository(); var output = new NewsPageViewModel { NewsPosts = repo.NewsPosts.Where(n => n.ViewState == 1).OrderByDescending(n => n.Timestamp) // 1 == Live }; return(View(MVC.Info.Views.GameNews, output)); }
public async Task <IActionResult> Index() { List <NewsDataModel> News_Eve24 = GetNewsEve24(); var model = new NewsPageViewModel() { News_Eve24 = News_Eve24 }; return(View(model)); }
public ActionResult Index(NewsListPage currentPage, int page = 0) { var repo = ServiceLocator.Current.GetInstance <IContentLoader>(); var pages = repo.GetChildren <NewsPage>(currentPage.ContentLink, currentPage.Language, page, MaxRows); var model = new NewsPageViewModel { CurrentPage = currentPage, ListOfNews = pages, NumberOfPages = repo.GetChildren <NewsPage>(currentPage.ContentLink).Count() }; return(View(model)); }
public ActionResult Index(NewsPage currentPage) { /* Implementation of action. You can create your own view model class that you pass to the view or * you can pass the page type for simpler templates */ NewsPageViewModel model = new NewsPageViewModel(currentPage) { CommentList = handler.LoadComments(currentPage.CommentFolder), HasCommentPublishAccess = handler.CurrentUserHasCommentPublishAccess(currentPage.CommentFolder), CommentFolderIsSet = handler.CommentFolderIsSet(currentPage.CommentFolder) }; return View(model); }
public ActionResult Index(NewsPage currentPage) { var model = new NewsPageViewModel(currentPage) { StartPage = loader.Get <StartPage>(ContentReference.StartPage), RootPage = loader.Get <SysRoot>(ContentReference.RootPage), MenuPages = FilterForVisitor.Filter( loader.GetChildren <SitePageData>(ContentReference.StartPage)) .Cast <SitePageData>().Where(page => page.VisibleInMenu), Section = currentPage.ContentLink.GetSection(), ArticlePages = loader.GetChildren <ArticlePage>(currentPage.ContentLink) }; return(View(model)); }
public IActionResult NewsOverview(int pageNumber, string category, [FromServices] GetNews getNews) { if (pageNumber < 1) { return(RedirectToAction("NewsOverview", new { pageNumber = 1, category })); } var news = string.IsNullOrEmpty(category) ? getNews.Do(PageSize, pageNumber) : getNews.Do(PageSize, pageNumber, category); int newsCount = string.IsNullOrEmpty(category) ? getNews.Count() : getNews.Count(category); int skipAmount = PageSize * (pageNumber - 1); int capacity = skipAmount + PageSize; var newsVm = new List <NewsViewModel>(); foreach (var singleNews in news) { newsVm.Add(new NewsViewModel { Id = singleNews.Id, Title = singleNews.Title, Body = singleNews.Body, ImagePath = singleNews.Image, Created = singleNews.Created, Description = singleNews.Description, Tags = singleNews.Tags, Category = singleNews.Category }); } newsVm = newsVm.OrderByDescending(x => x.Created).ToList(); var viewModel = new NewsPageViewModel { News = newsVm, PageNumber = pageNumber, Category = category, PageCount = (int)Math.Ceiling((double)newsCount / PageSize) }; if (newsCount > capacity) { viewModel.NextPage = true; } return(View(viewModel)); }
public NewsPageViewModel GetNewsPageViewModel() { List <Article> recentPosts = repository.Articles.OrderByDescending(x => x.DatePosted).Take(25).ToList(); List <Article> popularPosts = recentPosts.OrderByDescending(x => x.ViewCount).ToList(); while (popularPosts.Count < 7) { popularPosts.Add(new Article()); } var newsPageViewModel = new NewsPageViewModel() { MainPost = popularPosts[0], SecondaryPost = popularPosts[1], MainPostRelatedPosts = new List <Article>(), //recentPosts.Take(MainPostRelatedPostsCount).ToList(), //TODO: Implement related posts properly PostList = popularPosts.GetRange(2, PostListCount).ToList(), LatestPosts = recentPosts.Take(LatestPostsCount).ToList() }; return(newsPageViewModel); }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { SystemTray.SetBackgroundColor(this, Color.FromArgb(255, 24, 22, 22)); SystemTray.SetForegroundColor(this, Color.FromArgb(255, 255, 255, 254)); base.OnNavigatedTo(e); string id = ""; if (NavigationContext.QueryString.TryGetValue("id", out id)) { _vm = new NewsPageViewModel { News = App.MainViewModel.NewsPage.NewsList.Where(n => n.Model.Id == id).FirstOrDefault() }; if (_vm == null) { MessageBox.Show("Error", "Can't find news", MessageBoxButton.OK); NavigationService.GoBack(); } _vm.PropertyChanged += _vm_PropertyChanged; _vm.Load(id); } DataContext = _vm; }
public NewsPageViewModel GetNewsBoxesModel(int currentUmbracoPageId, string typeFromUrl) { var _model = new NewsPageViewModel(); _model.CurrentUmbracoPageId = currentUmbracoPageId; _model.CurrentPageCulture = Thread.CurrentThread.CurrentCulture; if (!string.IsNullOrEmpty(typeFromUrl)) { _model.SelectedTypeFromUrl = typeFromUrl.Trim(); } var _filterStateCookie = CookiesExtensions.GetCookieValue(CookieVariables.NewsFilterCookie); if (string.IsNullOrEmpty(_filterStateCookie)) { return(GetNewsBoxesModel(_model)); } var _filterModel = JsonConvert.DeserializeObject <NewsFilterStateViewModel>(StringExtensions.Base64Decode(_filterStateCookie)); if (_filterModel == null) { return(GetNewsBoxesModel(_model)); } if (_filterModel.NewsRegionFiltr.HasValue) { _model.SelectedRegionId = _filterModel.NewsRegionFiltr.Value; } if (_filterModel.NewsTypeFilter != null && _filterModel.NewsTypeFilter.Count > 0) { _model.SelectedTypeIds = _filterModel.NewsTypeFilter; } return(GetNewsBoxesModel(_model)); }
// News public ActionResult News(int pageIndex = 1, int?category = null) { int pageSize = 3; int totalRecords = 0; int totalFilteredRecords = 0; List <NewsViewModel> result = DataProvider .GetNews <NewsViewModel> ( out totalRecords, out totalFilteredRecords, new DbParameters <NewsViewModel> { PageIndex = pageIndex, PageSize = pageSize, SortOrder = "desc", Filters = category != null ? new NewsViewModel { CategoryId = (int)category } : null, } ) .ToList(); result.ForEach(x => x.MainPictureUrl = x.MainPictureUrl != null ? System.IO.Path.Combine(GetImagesFolderPath("News"), x.MainPictureUrl) : null); NewsPageViewModel model = new NewsPageViewModel { News = result, PageCount = (totalFilteredRecords > pageSize ? (int)Math.Ceiling((decimal)totalFilteredRecords / pageSize) : 1), PageInex = pageIndex, CategoryId = category }; return(View(model)); }
public ActionResult Index(NewsPage currentPage) { var model = new NewsPageViewModel(currentPage); return(View(model)); }
public NewsPage() { InitializeComponent(); vm = new NewsPageViewModel(); BindingContext = vm; }
public NewsPage(INewsService newsService) { _viewModel = new NewsPageViewModel(newsService); BindingContext = _viewModel; InitializeComponent(); }
public NewsPageViewModel GetNewsBoxesModel(NewsPageViewModel model) { var _newsNode = _umbracoHelper.TypedContent(model.CurrentUmbracoPageId); var _newsList = _newsNode.Children.Where("Visible").Select(q => new ArticleWithDoubleFiltr(q)); var _isParamFromUrl = !string.IsNullOrEmpty(model.SelectedTypeFromUrl); model.DisplayCount = new Information(_newsNode).DisplayItemsCount; #region Pobranie filtrów z bazy danych //Pobranie aktywnych filtrów z bazy danych var _regionFilterItemsFromDB = _dbService.GetAll <RegionDB>("PolRegioRegion", q => q.IsEnabled); var _newsTypeItemsFromDB = _dbService.GetAll <ArticleTypeDB>("PolRegioArticleType", q => q.IsEnabled); model.RegionFilter = _regionFilterItemsFromDB.Select(q => new FilterItem() { Id = q.Id, DisplayText = _umbracoHelper.GetDictionaryValue(q.DictionaryKey) }).ToList(); model.RegionFilter.Insert(0, new FilterItem() { Id = 0, DisplayText = _umbracoHelper.GetDictionaryValue("News.Placeholder.AllRegions") }); if (model.NewsTypeFilter == null) { model.NewsTypeFilter = _newsTypeItemsFromDB.Select(q => new CheckBoxFilterItem() { Id = q.Id, DisplayText = _umbracoHelper.GetDictionaryValue(q.DictionaryKey), IsChecked = (_isParamFromUrl && q.Name.ToLower() == model.SelectedTypeFromUrl.ToLower()) || (!_isParamFromUrl && model.SelectedTypeIds != null && model.SelectedTypeIds.Contains(q.Id)) }).ToList(); } var _selectedTypesId = model.NewsTypeFilter.Where(q => q.IsChecked).Select(q => q.Id); #region SetFilterStateCookie var _typesId = _selectedTypesId as IList <int> ?? _selectedTypesId.ToList(); var _filterModel = new NewsFilterStateViewModel() { NewsRegionFiltr = model.SelectedRegionId, NewsTypeFilter = _typesId.ToList() }; CookiesExtensions.CreateCookie(CookieVariables.NewsFilterCookie, StringExtensions.Base64Encode(JsonConvert.SerializeObject(_filterModel))); #endregion #endregion if (model.SelectedRegionId != 0) { var _departmentNode = new OfficeAccordion(_newsNode.AncestorOrSelf(DocumentTypeEnum.location.ToString()).DescendantOrSelf(DocumentTypeEnum.officeAccordion.ToString())); if (_departmentNode != null && _departmentNode.AddOffice != null) { var _contactRegionList = _departmentNode.AddOffice.Fieldsets.Where(x => x != null && x.Properties.Any() && !x.Disabled).Select(q => new RegionContactBox(q)); model.RegionContact = _contactRegionList.Where(q => q.Region != null).FirstOrDefault(q => q.Region.Key == model.SelectedRegionId.ToString()); } _newsList = _newsList.Where(q => q.ArticleRegions.SavedValue != null && JsonConvert.DeserializeObject <IEnumerable <NuPickersSqlDropDownPicker> >(q.ArticleRegions.SavedValue.ToString()).Any(c => c.Key == model.SelectedRegionId.ToString())); } if (_typesId.Count() > 0) { _newsList = _newsList.Where(q => q.ArticleCategory.SavedValue != null && _typesId.Contains(int.Parse(JsonConvert.DeserializeObject <IEnumerable <NuPickersSqlDropDownPicker> >(q.ArticleCategory.SavedValue.ToString()).Select(c => c.Key).FirstOrDefault()))); } model.AllNewsCount = _newsList.Count(); model.NewsBoxesList = _newsList .OrderByDescending(q => q.ListArticleDate) .Take(model.DisplayCount) .Select(q => new NewsBoxModel(q)); return(model); }
public ViewModelLocator() { try { var config = new ConfigurationBuilder(); config.AddJsonFile(Directory.GetParent(Environment.CurrentDirectory).Parent.FullName + "\\Resources\\autofac.json"); var module = new ConfigurationModule(config.Build()); var builder = new ContainerBuilder(); builder.RegisterModule(module); Container = builder.Build(); navigationService = Container.Resolve <INavigationService>(); appViewModel = Container.Resolve <AppViewModel>(); // LogInViewModel = Container.Resolve <LogInPageViewModel>(); MainDesktopPageViewModel = Container.Resolve <MainDesktopPageViewModel>(); CalendarPageViewModel = Container.Resolve <CalendarPageViewModel>(); AddEditEventPageViewModel = Container.Resolve <AddEditEventPageViewModel>(); GMailPageViewModel = Container.Resolve <GMailPageViewModel>(); ReadMailPageViewModel = Container.Resolve <ReadMailPageViewModel>(); SchedulePageViewModel = Container.Resolve <SchedulePageViewModel>(); DocumentsPageViewModel = Container.Resolve <DocumentsPageViewModel>(); NewsPageViewModel = Container.Resolve <NewsPageViewModel>(); SettingsPageViewModel = Container.Resolve <SettingsPageViewModel>(); ContactsPageViewModel = Container.Resolve <ContactsPageViewModel>(); ComposeNewMailPageViewModel = Container.Resolve <ComposeNewMailPageViewModel>(); AdminPanelPageViewModel = Container.Resolve <AdminPanelPageViewModel>(); AddNewUserPageViewModel = Container.Resolve <AddNewUserPageViewModel>(); NormativeInfoPageViewModel = Container.Resolve <NormativeInfoPageViewModel>(); AddNewsPageViewModel = Container.Resolve <AddNewsPageViewModel>(); NewsListPageViewModel = Container.Resolve <NewsListPageViewModel>(); ConstantsPageViewModel = Container.Resolve <ConstantsPageViewModel>(); ChangeMyPassPageViewModel = Container.Resolve <ChangeMyPassPageViewModel>(); CreateNewContactPageViewModel = Container.Resolve <CreateNewContactPageViewModel>(); DocPageViewModel = Container.Resolve <DocPageViewModel>(); ShowHistoryPageViewModel = Container.Resolve <ShowHistoryPageViewModel>(); navigationService.Register <LogInPageView>(LogInViewModel); navigationService.Register <MainDesktopPageView>(MainDesktopPageViewModel); navigationService.Register <CalendarPageView>(CalendarPageViewModel); navigationService.Register <AddEditEventPageView>(AddEditEventPageViewModel); navigationService.Register <GMailPageView>(GMailPageViewModel); navigationService.Register <ReadMailPageView>(ReadMailPageViewModel); navigationService.Register <SchedulePageView>(SchedulePageViewModel); navigationService.Register <DocumentsPageView>(DocumentsPageViewModel); navigationService.Register <NewsPageView>(NewsPageViewModel); navigationService.Register <SettingsPageView>(SettingsPageViewModel); navigationService.Register <ContactsPageView>(ContactsPageViewModel); navigationService.Register <ComposeNewMailPageView>(ComposeNewMailPageViewModel); navigationService.Register <AdminPanelPageView>(AdminPanelPageViewModel); navigationService.Register <AddNewUserPageView>(AddNewUserPageViewModel); navigationService.Register <NormativeInfoPageView>(NormativeInfoPageViewModel); navigationService.Register <AddNewsPageView>(AddNewsPageViewModel); navigationService.Register <NewsListPageView>(NewsListPageViewModel); navigationService.Register <ConstantsPageView>(ConstantsPageViewModel); navigationService.Register <ChangeMyPassPageView>(ChangeMyPassPageViewModel); navigationService.Register <CreateNewContactPageView>(CreateNewContactPageViewModel); navigationService.Register <DocPageView>(DocPageViewModel); navigationService.Register <ShowHistoryPageView>(ShowHistoryPageViewModel); navigationService.Navigate <LogInPageView>(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
void binddata() { IsPull = true; BindingContext = new NewsPageViewModel(); IsPull = false; }