Пример #1
0
        public ActionResult GetAll(string id)
        {
            var book    = _bookService.GetAll(id);
            var booksVm = _mapper.Map <List <BookViewModel> >(book);

            var data = new GetBooksViewModel
            {
                Books = booksVm
            };

            return(View(data));
        }
        public ActionResult GetBookByCuurentUser()
        {
            var viewModel = new GetBooksViewModel()
            {
                Books = UnitOfWork.BookRepository.Find(x => x.User.Id == GetUserId())
                        .Include(y => y.User)
                        .Include(z => z.Category)
                        .OrderByDescending(v => v.CreatedAt)
                        .ToList()
            };

            return(View("Index", viewModel));
        }
        public ActionResult Index()
        {
            var viewModel = new GetBooksViewModel()
            {
                Books = UnitOfWork.BookRepository.GetAll()
                        .Where(z => z.Draft == false)
                        .Include(x => x.User)
                        .Include(y => y.Category)
                        .OrderByDescending(v => v.CreatedAt)
                        .ToList()
            };

            return(View(viewModel));
        }