public ElectionArticlesViewModel(HDPApp _app) { Title = "Secim"; PlayVideoCommand = ReactiveCommand.CreateAsyncTask (async videoId => { return (string)videoId; }); var gotoElectionArticle = new Action<ElectionArticleItemViewModel> (x => { if (x.MediaType == ElectionArticle.MediaType.Video) { PlayVideoCommand.Execute(x.VideoId); } }); ArticleItems = _app.State.ElectionArticles.CreateDerivedCollection ( x => new ElectionArticleItemViewModel (x, gotoElectionArticle, true), orderer: (x, y) => x.CreatedAt.CompareTo (y.CreatedAt) * -1); this.WhenAnyValue (x => x.ArticleItems.Count) .Select (x => x == 0) .ToProperty (this, x => x.IsLoading, out _isLoading, true); RefreshContent = ReactiveCommand.CreateCombined ( _app.FetchNewElectionArticles.CanExecuteObservable, _app.FetchNewElectionArticles); }
public NewsViewModel(HDPApp application) { _application = application; Title = "Haberler"; var gotoArticle = new Action<ArticleItemViewModel> (x => { var vm = this.CreateViewModel<ArticleViewModel>(); vm.ArticleTitle = x.Model.Title; vm.Body = x.Model.Body; vm.ImageUrl = x.Model.ImageUrl; vm.CreatedAt = x.Model.CreatedAt; NavigateTo(vm); }); ArticleItems = _application.State.Articles.CreateDerivedCollection ( x => new ArticleItemViewModel (x, gotoArticle), x => true, (x, y) => x.Model.CreatedAt.CompareTo(y.Model.CreatedAt) * -1); this.WhenAnyValue (x => x.ArticleItems.Count) .Select (x => x == 0) .ToProperty (this, x => x.IsLoading, out _isLoading, true); RefreshContent = ReactiveCommand.CreateCombined ( _application.FetchNewArticles.CanExecuteObservable, _application.FetchNewArticles); }
public OrganizationMenuViewModel(HDPApp _app) { Title = "Parti"; Action<OrganizationMenuItemViewModel> gotoCommand = null; gotoCommand = new Action<OrganizationMenuItemViewModel> (x => { if (x.Model.MenuType == MenuType.View) { var page = x.Model.Page; var vm = new OrganizationPageViewModel(); vm.Title = page.Title; vm.Document = page.Document; NavigateTo(vm); } else if (x.Model.MenuType == MenuType.SubMenu) { var subMenuItemVM = new OrganizationSubMenuItemViewModel(x.Model, gotoCommand); subMenuItemVM.Title = x.Title; NavigateTo(subMenuItemVM); } }); OrganizationItems = _app.State.OrganizationMenuItems.CreateDerivedCollection ( x => new OrganizationMenuItemViewModel (x, gotoCommand)); }
public EventsViewModel(HDPApp _app) { Title = "Etkinlikler"; EventItems = _app.State.Events.CreateDerivedCollection ( x => new EventItemViewModel(x), orderer: (x, y) => y.Model.Time.CompareTo(x.Model.Time)); this.WhenAnyValue (x => x.EventItems.Count) .Select (x => x == 0) .ToProperty (this, x => x.IsLoading, out _isLoading, true); RefreshContent = ReactiveCommand.CreateCombined ( _app.FetchNewEvents.CanExecuteObservable, _app.FetchNewEvents); }