Ejemplo n.º 1
0
        public ActionResult Index()
        {
            var postViewModel = new PostIndexViewModel
            {
                Title = "Title",
                Subtitle = "SubTitle"
            };

            return View(postViewModel);
        }
Ejemplo n.º 2
0
        public ActionResult Index(PostIndexViewModel model)
        {
            if (ModelState.IsValid)
            {
                // TODO: save

                return this.RedirectToAction("Index");
            }

            return View("Index", model);
        }
Ejemplo n.º 3
0
        public IActionResult Index(int id = 1)
        {
            var posts = this.postsService.GetAll <PostViewModel>(PostsPerPage, (id - 1) * PostsPerPage);

            var viewModel = new PostIndexViewModel {
                Posts = posts
            };

            var count = this.postsService.GetCount();

            var pagination = new PaginationViewModel();

            pagination.PagesCount = (int)Math.Ceiling((double)count / PostsPerPage);
            if (pagination.PagesCount == 0)
            {
                pagination.PagesCount = 1;
            }

            pagination.CurrentPage = id;

            viewModel.Pagination = pagination;

            return(this.View(viewModel));
        }
        public IActionResult Details(int id)
        {
            var post   = _postRepository.GetPublishedPostById(id);
            int userId = GetCurrentUserProfileId();

            if (post == null)
            {
                post = _postRepository.GetUserPostById(id, userId);
                if (post == null)
                {
                    return(NotFound());
                }
            }
            post.Tags         = _postTagRepo.GetPostTags(id);
            post.IsSubscribed = _subRepo.IsSubscribed(new SubscribeViewModel()
            {
                SubscriberUserId = userId, ProviderUserId = post.UserProfileId
            });
            var vm = new PostIndexViewModel();

            vm.PostModel = post;
            vm.UserId    = GetCurrentUserProfileId();
            return(View(vm));
        }
Ejemplo n.º 5
0
        public ActionResult InformalWall()
        {
            var user = User.Identity.GetUserId();

            ViewBag.loggedInUser = user;
            var blogDB   = new BlogDbContext();
            var loggedIn = blogDB.Profiles.FirstOrDefault(x => x.ProfileID == user);

            ViewBag.isAdmin = loggedIn.AdminRights;

            var blogPosts = blogDB.Posts.ToList();

            blogPosts.Reverse();

            var viewModel = new PostIndexViewModel
            {
                Profiles   = blogDB.Profiles.ToList(),
                Posts      = blogPosts,
                Categories = blogDB.Categories.ToList(),
                Comments   = blogDB.Comments.ToList()
            };

            return(View(viewModel));
        }
Ejemplo n.º 6
0
        public IActionResult Index(int id)
        {
            var post = _postService.GetById(id);

            var replies = BuildPostReplies(post.Replies);

            var model = new PostIndexViewModel
            {
                Id             = post.Id,
                Title          = post.Title,
                AuthorId       = post.User.Id,
                AuthorName     = post.User.UserName,
                AuthorImageUrl = post.User.ProfileImageUrl,
                AuthorRating   = post.User.Rating,
                Created        = post.Created,
                PostContent    = post.Content,
                Replies        = replies,
                ForumId        = post.Forum.Id,
                ForumName      = post.Forum.Title,
                IsAuthorAdmin  = IsAuthorAdmin(post.User),
            };

            return(View(model));
        }