Esempio n. 1
0
        // 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));
        }
Esempio n. 2
0
 public async Task <List <Post> > GetPosts()
 {
     return(await _postsRepo.GetAllPosts());
 }
        public ViewResult SeePosts()
        {
            var model = _postsRepository.GetAllPosts();

            return(View(model));
        }
Esempio n. 4
0
 public IEnumerable <Post> GetAllPosts()
 {
     return(repository.GetAllPosts());
 }
Esempio n. 5
0
    public ActionResult Index()
    {
        var posts = _repository.GetAllPosts();

        return(View(posts));
    }
Esempio n. 6
0
 public async Task <IEnumerable <Post> > GetAllPosts()
 {
     return(await _postsRepository.GetAllPosts());
 }