示例#1
0
        public async Task <IActionResult> Create(int id)
        {
            //Get post and track for reply
            var postReply = _postReplyService.GetById(id);

            //Get the application user that will write the reply for this post
            var user = await _userManager.FindByNameAsync(User.Identity.Name);

            var model = new PostReplySupportingBibleVerseModel
            {
                AuthorName     = User.Identity.Name,
                AuthorImageUrl = user.ImageUrl,
                AuthorId       = user.Id,
                AuthorRating   = user.Rating,
                IsAuthorAdmin  = User.IsInRole("Admin"),

                Created = DateTime.Now,

                PostId      = postReply.Post.Id,
                PostTitle   = postReply.Post.Title,
                PostReplyId = postReply.Id
            };

            return(View(model));
        }
示例#2
0
        //Edit
        public async Task <IActionResult> Edit(int id)
        {
            //Get post and track for reply
            var postReply = _postReplyService.GetById(id);

            //Get the application user that will write the reply for this post
            var user = await _userManager.FindByNameAsync(User.Identity.Name);

            var model = new PostReplyEditModel
            {
                Id             = postReply.Id,
                AuthorName     = User.Identity.Name,
                AuthorImageUrl = user.ImageUrl,
                AuthorId       = user.Id,
                AuthorRating   = user.Rating,
                IsAuthorAdmin  = User.IsInRole("Admin"),

                Created      = postReply.Created,
                ReplyContent = postReply.Content,

                EditedCreatedDate = DateTime.Now,
                VoteCount         = postReply.VoteCount,
                IsEdited          = postReply.IsEdited,

                PostId        = postReply.Post.Id,
                ForumId       = postReply.Post.Forum.Id,
                ForumImageUrl = postReply.Post.Forum.ImageUrl,
                ForumName     = postReply.Post.Forum.Title
            };

            return(View(model));
        }
示例#3
0
        public async Task <IActionResult> Create(int id)
        {
            //Get postReplyID and track for reply
            var postReply = _postReplyService.GetById(id);

            //Get postID and track for reply
            var post = _postService.GetById(postReply.Post.Id);

            //Get the application user that will write the reply for this post
            var user = await _userManager.FindByNameAsync(User.Identity.Name);

            var model = new PostReplyReplyModel
            {
                PostId              = post.Id,
                PostReplyId         = postReply.Id,
                PostReplyContent    = postReply.Content,
                ReplyOriginalAuthor = postReply.User.UserName,
                AuthorName          = User.Identity.Name,
                AuthorImageUrl      = user.ImageUrl,
                AuthorId            = user.Id,
                AuthorRating        = user.Rating,
                IsAuthorAdmin       = User.IsInRole("Admin"),

                Created = DateTime.Now
            };

            return(View(model));
        }
        //Voting
        public async Task <IActionResult> Vote(int id)
        {
            var postReply = _postReplyService.GetById(id);

            var userId = _userManager.GetUserId(User);
            var user   = await _userManager.FindByIdAsync(userId);

            var vote = BuildVote(postReply.Id, user);

            await _postReplyLikeService.Add(vote);

            return(RedirectToAction("Index", "Post", new { id = postReply.Post.Id }));
        }
示例#5
0
        public IActionResult Index(int id)
        {
            int userid;
            var identity = (ClaimsIdentity)User.Identity;
            IEnumerable <Claim> claims = identity.Claims;

            try
            {
                userid = int.Parse(claims.ElementAt(2).Value);
            }
            catch (Exception)
            {
                userid = 0;
            }
            var post    = _post.GetById(id);
            var user    = _user.GetById(post.User.Id);
            var forum   = _forum.GetById(post.Forum.Id);
            var replies = _postReply.GetById(post.Id);
            var model   = new PostIndexModel
            {
                RatedByUser = _post.CheckLikeByUserId(userid, id),
                Rating      = _post.GetRatingById(id),
                Post        = post,
                User        = user,
                Forum       = forum,
                Replies     = replies
            };

            return(View(model));
        }
示例#6
0
        public List <PostReply> GetById(int id)
        {
            var returnedList = _context.GetById(id);

            for (int i = 0; i < returnedList.Count; i++)
            {
                returnedList[i].User = _userContext.GetById(returnedList[i].User.Id);
            }
            return(returnedList);
        }