// GET: /<controller>/ //Home/Index public async Task <IActionResult> Index(string search) { //var model = repository.GetAllPosts(); MasterOneVM model = new MasterOneVM(); //if (User.Identity.IsAuthenticated) //{ // var user = await userManager.FindByNameAsync(User.Identity.Name); // model.IsUserAdmin = await userManager.IsInRoleAsync(user, "Admin"); //} var posts = from m in dbContext.Posts select m; //Search if (!String.IsNullOrEmpty(search)) { model.BlogPosts = repository.GetSearch(search); } else { model.BlogPosts = repository.GetAllPosts(); } model.Categories = repository.GetAllCategories(); //var model = new PostListVM(); //model.Categories = repository.GetAllCategories(); //return View(model); return(View(model)); }
public IViewComponentResult Invoke() { //var model = _postsRepository.GetAllPosts(); MasterOneVM model = new MasterOneVM(); model.Categories = _postsRepository.GetAllCategories(); return(View(model)); }
//BlogPost public IActionResult BlogPost(int myTitle, string search) { MasterOneVM model = new MasterOneVM(); //Search if (!String.IsNullOrEmpty(search)) { model.BlogPosts = repository.GetSearch(search); } else { model.BlogPosts = repository.GetOnePost(myTitle); model.Categories = repository.GetAllCategories(); } return(View(model)); }