Exemplo n.º 1
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            var vm = new BooksPageViewModel();

            vm.Initialize();

            BindingContext = vm;
        }
        public BooksPage()
        {
            var bookStore   = new BookStoreService();
            var pageService = new PageService();

            ViewModel = new BooksPageViewModel(bookStore, pageService);

            InitializeComponent();

            ViewModel.LoadBooksCommand.Execute(null);
        }
Exemplo n.º 3
0
        private async Task <BooksPageViewModel> GetBooksPage(int page)
        {
            IQueryable <Book> source = _db.Books.Where(b => b.Quantity > 0);
            int count = await source.CountAsync();

            int totalPages = (int)Math.Ceiling(count / (double)_pageSize);

            if (page < 1)
            {
                page = 1;
            }
            else if (page > totalPages)
            {
                page = totalPages;
            }
            var books = await source.Skip((page - 1) *_pageSize).Take(_pageSize).ToListAsync();

            BooksPageViewModel pageViewModel = new BooksPageViewModel(page, _pageSize, totalPages, books);

            return(pageViewModel);
        }
Exemplo n.º 4
0
 public BooksPage()
 {
     InitializeComponent();
     DataContext = new BooksPageViewModel();
 }
Exemplo n.º 5
0
 public BooksPage(string genrePath)
 {
     InitializeComponent();
     vm             = new BooksPageViewModel(genrePath);
     BindingContext = vm;
 }
Exemplo n.º 6
0
 public BooksPage()
 {
     InitializeComponent();
     vm             = new BooksPageViewModel();
     BindingContext = vm;
 }