Ejemplo n.º 1
0
        //GET /books
        public async Task <IActionResult> Index(int p = 1)
        {
            int pageSize = 6;
            var books    = context.Books.OrderByDescending(x => x.Id).Skip((p - 1) * pageSize).Take(pageSize);

            BooksGroupViewModel booksGroupVM = new BooksGroupViewModel(await books.ToListAsync(),
                                                                       p,
                                                                       pageSize,
                                                                       (int)Math.Ceiling((decimal)context.Books.Count() / pageSize)
                                                                       );

            return(View(booksGroupVM));
        }
Ejemplo n.º 2
0
        //GET /books/genre
        public async Task <IActionResult> BooksByGenre(string genreSlug, int p = 1)
        {
            Genre genre = await context.Genres.Where(x => x.Slug == genreSlug).FirstOrDefaultAsync();

            if (genre == null)
            {
                return(RedirectToAction("Index"));
            }

            int pageSize = 6;
            var books    = context.Books.OrderByDescending(x => x.Id).Where(x => x.GenreId == genre.Id)
                           .Skip((p - 1) * pageSize).Take(pageSize);

            BooksGroupViewModel booksGroupVM = new BooksGroupViewModel(await books.ToListAsync(),
                                                                       p,
                                                                       pageSize,
                                                                       (int)Math.Ceiling((decimal)context.Books.Count(x => x.GenreId == genre.Id) / pageSize),
                                                                       genre.Name,
                                                                       genreSlug
                                                                       );

            return(View(booksGroupVM));
        }
Ejemplo n.º 3
0
 public BookVersesMemorizedPage(BooksGroupViewModel viewModel)
 {
     InitializeComponent();
     this.ViewModel = viewModel;
     Title          = "Memory Book Groups";
 }