示例#1
0
        public ActionResult AuthorPage(int?page, string name)
        {
            BlogEntities        db        = new BlogEntities();
            AuthorPageViewModel viewModel = new AuthorPageViewModel();
            string sql = "";

            if (name == null || name == "")
            {
                return(RedirectToAction("ListPost"));
            }

            List <PostViewModel> tmpList = db.POSTs.Where(c => c.CREATED_USER == name).Select(c => new PostViewModel {
                TITLE = c.TITLE, IMAGE_COVER = c.IMAGE_COVER, SLUG = c.SLUG, CREATED_DATE = c.CREATED_DATE, CREATED_USER = c.CREATED_USER, MAIN_TAG = c.MAIN_TAG, META_DESC = c.META_DESC
            }).ToList();
            int pageSize   = 5;
            int pageNumber = (page ?? 1);

            viewModel.ListPost = tmpList.ToPagedList(pageNumber, pageSize);

            viewModel.User = db.PAGE_USER.FirstOrDefault(c => c.USERNAME == name);

            if (viewModel.User == null || viewModel.ListPost == null)
            {
                return(RedirectToAction("ListPost"));
            }

            return(View(viewModel));
        }
示例#2
0
        // GET: Author
        public ActionResult Index()
        {
            AuthorPageViewModel viewModel = new AuthorPageViewModel();

            viewModel.ItemList = _authorService.GetAllAuthors();
            return(View(viewModel));
        }
示例#3
0
        public ActionResult Index()
        {
            SetListsForViews();
            Book book = new Book();
            AuthorPageViewModel author = new AuthorPageViewModel();

            //ViewBag.List = author.BooksResult.ToList();

            author.BooksResult = book.GetAll();

            return(View(author));
        }
示例#4
0
        public AuthorPageViewModel GetAuthorPageViewModel(int authorId)
        {
            var model = new AuthorPageViewModel
            {
                Author       = Get(authorId),
                NewsCount    = _newsService.FindBy(news => news.AuthorId == authorId).Count(),
                CommentCount = 0
            };


            return(model);
        }
示例#5
0
        public ActionResult Index(AuthorPageViewModel author)
        {
            SetListsForViews();
            if (ModelState.IsValid)
            {
                Book book = new Book();

                var books = book.GetAll();

                if (!String.IsNullOrEmpty(author.Keyword))
                {
                    books = books.Where(b => b.Title.ToLower().Contains(author.Keyword.ToLower())).ToList();
                }
                author.BooksResult = books;
            }
            return(View(author));
        }
示例#6
0
 private void OnPageLoaded(object sender, RoutedEventArgs e)
 {
     this.ViewModel = DataContext as AuthorPageViewModel;
     ViewModel.CallService();
 }