public async Task <IActionResult> AddReply(ReplyModel model)
        {
            var userId = _userManager.GetUserId(User);
            var user   = await _userManager.FindByIdAsync(userId);

            var reply = BuildReplyEntity(model, user);
            await _postService.AddReply(reply);

            return(RedirectToAction("Index", "Post", new { id = model.PostId }));
        }
Пример #2
0
        public async Task <ActionResult> AddReply(PostReplyModel model)
        {
            var userId = User.Identity.GetUserId();
            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 }));
        }
Пример #3
0
        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);
            _userService.IncrementRating(user.Id, typeof(PostReply));
            return(RedirectToAction("Index", "Post", new { postId = model.PostId }));
        }
Пример #4
0
        public async Task <IActionResult> AddReply(PostReplyModel model)
        {
            var userId = _userManager.GetUserId(User);
            var user   = await _userManager.FindByIdAsync(userId);

            var reply = BuildReply(model, user);

            if (model.ReplyContent != null)
            {
                await _postService.AddReply(reply);

                await _userService.BumpRating(userId, typeof(PostReply));
            }

            return(RedirectToAction("Index", "Post", new { id = model.PostId }));
        }
        public async Task <IActionResult> AddReply(PostReplyModel model)
        {
            if (ModelState.IsValid)
            {
                var userId = _userManager.GetUserId(User);
                var user   = await _userManager.FindByIdAsync(userId);

                var reply = BuildReply(model, user);
                model.ForumName = reply.Post.Forum.Title;
                reply.User.Rating++;
                await _postService.AddReply(reply);

                return(RedirectToAction("Index", "Post", new { id = model.PostId }));
            }

            return(await Create(model.PostId));
        }
Пример #6
0
        public async Task <IActionResult> AddReply(PostReplyModel model)
        {
            if (model == null)
            {
                return(NotFound());
            }
            var userId = _userManager.GetUserId(User);
            var user   = await _userManager.FindByIdAsync(userId).ConfigureAwait(false);

            var reply = BuildReply(model, user) as PostReply;

            await _postService.AddReply(reply).ConfigureAwait(false);

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

            return(RedirectToAction("Index", "Post", new { id = model.PostId }));
        }
Пример #7
0
        public async Task <IActionResult> AddReply(PostReplyModel model)
        {
            var userId = _userManager.GetUserId(User);
            var user   = await _userManager.FindByIdAsync(userId);

            //var post = _postService.GetById(model.PostId);
            //var imageUri = "";
            //if (model.ReplyImageUpload != null && model.ReplyImageUpload.Length != 0)
            //{
            //    //var blockBlob = UploadForumImage(model.ImageUpload);
            //    //imageUri = blockBlob.Uri.AbsoluteUri;
            //    string pathRoot = _environment.WebRootPath;
            //    string path_to_Images = pathRoot + "\\Images\\replies\\" + model.ReplyImageUpload.FileName;

            //    using (var stream = new FileStream(path_to_Images, FileMode.Create))
            //    {
            //        await model.ReplyImageUpload.CopyToAsync(stream);
            //    }

            //    imageUri = "/Images/replies/" + model.ReplyImageUpload.FileName;
            //}
            //PostReply reply = new PostReply
            //{
            //    Post = post,
            //    Content = model.ReplyContent,
            //    Created = DateTime.Now,
            //    User = user,
            //    ImageUrl = imageUri
            //};
            PostReply reply = await BuildReplyModel(model, user);

            await _postService.AddReply(reply);

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

            return(RedirectToAction("Index", "Post", new { id = model.PostId }));
        }