예제 #1
0
        public ActionResult Index()
        {
            var model = new PostsViewModel
            {
                Posts          = _postService.Get(string.Empty, false),
                PostCategories = _postCategoryService.Get()
            };

            return(View(model));
        }
예제 #2
0
 public IActionResult Get(string keyWord = "", string sortColunm = "", int pageIndex = 0, int pageSize = 15)
 {
     return(DoActionWithReturnResult(() =>
     {
         var listPostCategory = _postCategoryService.Get(pageIndex, pageSize, keyWord, sortColunm);
         return ResponseDataSuccess(listPostCategory);
     }));
 }
예제 #3
0
        public IActionResult UpdatePostCategory(int id)
        {
            var model = _postCategoryService.Get(x => x.Id == id);
            var postCategoryViewModel = new PostCategoryViewModel()
            {
                Id = model.Id, Title = model.Title
            };

            return(View(postCategoryViewModel));
        }
예제 #4
0
        public IActionResult Edit(Guid id)
        {
            var category = _categoryService.Get(id);

            if (category == null)
            {
                return(NotFound());
            }

            return(View(category));
        }
예제 #5
0
        public ActionResult Edit(int postCategoryId)
        {
            var postCategory = _postCategoryService.Get(postCategoryId);

            var model = new EditViewModel
            {
                PostCategoryId   = postCategoryId,
                PostCategoryName = postCategory.PostCategoryName
            };

            return(View("_Edit", model));
        }
예제 #6
0
        public async Task <IActionResult> IndexByCategoryAsync(string id, int page = 1)
        {
            var posts = _postService.FilterByPostedDate(_postService.GetAll(_categoryService.Get(Guid.Parse(id))));

            if (posts == null)
            {
                return(NotFound());
            }

            var count = await posts.CountAsync();

            var items = await posts.Skip((page - 1) *pageSize).Take(pageSize).ToListAsync();

            PageViewModel  pageViewModel = new PageViewModel(count, page, pageSize);
            PostsViewModel viewModel     = new PostsViewModel
            {
                PageViewModel = pageViewModel,
                Posts         = items
            };

            return(View(viewModel));
        }