public ActionResult Index() { var model = new PostsViewModel { Posts = _postService.Get(string.Empty, false), PostCategories = _postCategoryService.Get() }; return(View(model)); }
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); })); }
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)); }
public IActionResult Edit(Guid id) { var category = _categoryService.Get(id); if (category == null) { return(NotFound()); } return(View(category)); }
public ActionResult Edit(int postCategoryId) { var postCategory = _postCategoryService.Get(postCategoryId); var model = new EditViewModel { PostCategoryId = postCategoryId, PostCategoryName = postCategory.PostCategoryName }; return(View("_Edit", model)); }
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)); }