示例#1
0
        public async Task <IActionResult> Create(int id)
        {
            var post = _postService.GetById(id);
            var user = await _userManager.FindByNameAsync(User.Identity.Name);

            var model = new PostReplyViewModel
            {
                PostContent = post.Content,
                PostTitle   = post.Title,
                PostId      = post.Id,

                AuthorId       = user.Id,
                AuthorName     = User.Identity.Name,
                AuthorImageUrl = user.ProfileImageUrl,
                AuthorRating   = user.Rating,
                IsAuthorAdmin  = User.IsInRole("admin"),

                ForumName     = post.Forum.Title,
                ForumId       = post.Forum.Id,
                ForumImageUrl = post.Forum.ImageUrl,

                DateCreated = DateTime.Now,
            };

            return(View(model));
        }
示例#2
0
        // GET
        public async Task <IActionResult> Create(int id)
        {
            var post = _postService.GetById(id);

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

            var model = new PostReplyViewModel
            {
                PostContent = post.Content,
                PostTitle   = post.Title,
                PostId      = post.Id,

                AuthorId      = user.Id,
                AuthorName    = User.Identity.Name,
                AuthorRating  = user.Rating,
                IsAuthorAdmin = User.IsInRole("Admin"),

                ForumId   = post.Forum.Id,
                ForumName = post.Forum.Title,

                DateCreated = DateTime.Now
            };

            return(View(model));
        }
示例#3
0
        public async Task <IActionResult> Create(int id)
        {
            var post  = this.postsService.GetById(id);
            var forum = this.forumsService.GetById(post.Forum.Id);
            var user  = await this.usersManager.FindByNameAsync(this.User.Identity.Name);

            var model = new PostReplyViewModel
            {
                AuthorId       = user.Id,
                AuthorName     = this.User.Identity.Name,
                AuthorImageUrl = user.ProfileImageUrl,
                AuthorRating   = user.Rating,
                CreatedOn      = user.CreatedOn,

                PostId      = post.Id,
                PostTitle   = post.Title,
                PostContent = post.Content,

                ForumId       = forum.Id,
                ForumTitle    = forum.Title,
                ForumImageUrl = forum.ImageUrl,
                IsAuthorAdmin = this.User.IsInRole("Administrator"),
            };

            return(this.View(model));
        }
示例#4
0
        public ActionResult PostReplyDetails(int id)
        {
            var model = new PostReplyViewModel(forumClient.GetPostReplyById(id));

            ViewBag.ResponseList = forumClient.GetReplyResponseListByPostId(id);

            return(View(model));
        }
示例#5
0
        private PostReply BuildReply(PostReplyViewModel model, User user)
        {
            var post = _postService.GetById(model.PostId);

            return(new PostReply
            {
                Post = post,
                Content = model.ReplyContent,
                Created = DateTime.Now,
                User = user
            });
        }
        public async Task <IActionResult> AddReply(PostReplyViewModel model)
        {
            var userId = _userManager.GetUserId(User);
            var user   = await _userManager.FindByIdAsync(userId);

            var reply = BuildReply(model, user);

            await _postService.AddReply(reply);

            await _userService.UpdateUserRating(userId, typeof(PostReply));

            return(RedirectToAction("Index", "Post", new { id = model.PostId }));
        }
        public IActionResult AddReply(PostReplyViewModel model)
        {
            var user = _userManager.FindByIdAsync(model.AuthorId).Result;
            var post = _postService.GetById(model.PostId);

            var reply = new PostReply
            {
                Post    = post,
                Content = model.ReplyContent,
                Created = DateTime.Now,
                User    = user,
            };

            _postService.AddReply(reply);
            _userServce.IncementRating(user.Id, typeof(PostReply));
            return(RedirectToAction("Index", "Post", new { postId = model.PostId }));
        }
示例#8
0
        public async Task <IActionResult> AddReply(PostReplyViewModel model)
        {
            var userId = this.usersManager.GetUserId(this.User);
            var user   = await this.usersManager.FindByIdAsync(userId);

            var post  = this.postsService.GetById(model.PostId);
            var reply = new PostReply
            {
                Post      = post,
                Content   = model.ReplyContent,
                User      = user,
                CreatedOn = DateTime.UtcNow,
            };

            await this.postsService.AddReply(reply);

            return(this.RedirectToAction("Index", "Posts", new { id = model.PostId }));
        }
        public IActionResult Create(int postId)
        {
            var post = _postService.GetById(postId);
            var user = _userManager.FindByNameAsync(User.Identity.Name).Result;

            var model = new PostReplyViewModel
            {
                PostContent = post.Content,
                PostTitle   = post.Title,
                PostId      = post.Id,
                ForumName   = post.Forum.Title,

                AuthorId       = user.Id,
                AuthorName     = user.UserName,
                AuthorImageUrl = user.ProfileImageUrl,
                AuthorRating   = user.Rating,
                IsAuthorAdmin  = _userManager.GetRolesAsync(post.User).Result.Contains("admin"),

                Created = DateTime.Now
            };

            return(View(model));
        }
示例#10
0
 public void EditPostReply(PostReplyViewModel post)
 {
     _postReplyService.Update(_mapper.Map <PostReply>(post));
 }
示例#11
0
 public void CreatePostReply(PostReplyViewModel post)
 {
     _postReplyService.Insert(_mapper.Map <PostReply>(post));
 }