示例#1
0
 public async void GoToPostsPage(PostsPageViewModel viewModel, bool canGoBack)
 {
     await GoToPage(new PostsPage()
     {
         BindingContext = viewModel ?? _container.Resolve <PostsPageViewModel>()
     }, canGoBack);
 }
示例#2
0
        public ActionResult Search(int?id, string searchTerm)
        {
            PostsPageViewModel model = new PostsPageViewModel();

            if (id == null)
            {
                id = 1;
            }

            model.PageNumber = id.Value;
            model.Posts      = _repo.SearchResults(id, searchTerm);
            model.MaxPages   = _repo.GetPostMaxPagesBySearchTerm(searchTerm);
            model.SearchTerm = searchTerm;

            if (!string.IsNullOrWhiteSpace(searchTerm))
            {
                return(View(model));
            }
            else
            {
                return(View(new PostsPageViewModel {
                    Posts = new List <Post>()
                }));
            }
        }
        public PostsPage()
        {
            var pageService = new PageService();

            ViewModel = new PostsPageViewModel(pageService);

            InitializeComponent();
        }
示例#4
0
        // GET: Post
        public ActionResult Index(int id = 1)
        {
            var posts = _repo.GetApprovedPostByPageNumber(id);

            PostsPageViewModel model = new PostsPageViewModel();

            model.Posts      = posts;
            model.PageNumber = id;
            model.MaxPages   = _repo.GetTotalNumberOfPages();

            return(View(model));
        }
示例#5
0
        public PostsPage()
        {
            InitializeComponent();
            InitializeApplicationBar();

            _viewModel  = new PostsPageViewModel();
            DataContext = _viewModel;

            _viewModel.ViewStateChanged   += ViewStateChanged;
            _viewModel.ScrollTargetLoaded += ScrollTargetLoaded;
            _viewModel.CaptchaFocused     += CaptchaFocused;

            OrientationChanged += PostsPage_OrientationChanged;
        }
        public async Task It_Should_GetAll()
        {
            // TODO #172359: Find a cuter way to test the reactive properties.

            var viewModel    = new PostsPageViewModel();
            var testObserver = new TestObserver <ImmutableList <PostData> >(2);

            var postsProperty = viewModel.GetProperty <ImmutableList <PostData> >(nameof(viewModel.Posts));

            postsProperty.GetAndObserve().Subscribe(testObserver);

            await testObserver.ExpectedNotifications;

            testObserver.Values[0].Should().BeNull();
            testObserver.Values[1].Should().NotBeEmpty();
        }
示例#7
0
        public ActionResult PostView(int id = 1)
        {
            var repository           = DIContainer.Kernel.Get <IRepository>();
            PostsPageViewModel model = new PostsPageViewModel();

            if (User.IsInRole("Contributor"))
            {
                string userName = User.Identity.Name;
                var    posts    = repository.GetApprovedPostByPageNumberContributor(id, userName);
                model.Posts      = posts.Where(x => x.User.UserName == User.Identity.Name).ToList();
                model.PageNumber = id;
                model.MaxPages   = _repo.GetTotalNumberOfPagesContributor(userName);
            }
            else
            {
                var posts = repository.GetApprovedPostByPageNumber(id);
                model.Posts      = posts;
                model.PageNumber = id;
                model.MaxPages   = _repo.GetTotalNumberOfPages();
            }
            return(View(model));
        }
示例#8
0
 public void GoToPostsPage(PostsPageViewModel viewModel, bool canGoBack)
 {
     Device.BeginInvokeOnMainThread(() =>
                                    OnOpenPostsPage?.Invoke(viewModel, canGoBack));
 }