示例#1
0
        public async Task <IActionResult> AddCommentReplyLike([FromBody] VideoCommentReplyVM vm)
        {
            if (vm.VideoCommentReplyId <= 0)
            {
                return(NotFound());
            }

            var user = await _userManager.FindByIdAsync(User.Identity.Name);

            if (user == null)
            {
                return(NotFound());
            }

            CommentReplyLike commentReplyLike = new CommentReplyLike
            {
                UserId = user.Id,
                VideoCommentReplyId = vm.VideoCommentReplyId
            };

            await _vcrlRepository.AddAsync(commentReplyLike);

            await _vcrlRepository.CommitAsync();

            return(CreatedAtRoute("FindUserLikedCommentReply", new
            {
                controller = "CardDetail",
                id = commentReplyLike.VideoCommentReplyId
            }, null));
        }
示例#2
0
        public async Task <IActionResult> AddVideoCommentReplyReply([FromBody] VideoCommentReplyVM vm)
        {
            if (!ModelState.IsValid)
            {
                string errorMsg = null;
                foreach (var m in ModelState.Values)
                {
                    foreach (var msg in m.Errors)
                    {
                        errorMsg = msg.ErrorMessage;
                    }
                }
                return(BadRequest(errorMsg));
            }

            var user = await _userManager.FindByIdAsync(User.Identity.Name);

            if (user == null)
            {
                return(NotFound());
            }

            var ipAddress = _clientIP.GetClientIP();
            //var countryCode = await _clientIP.GetCountryCodeByIP(ipAddress);

            VideoCommentReply newVideoCommentReply = new VideoCommentReply
            {
                Comment           = vm.Comment,
                DateCreated       = DateTime.Now,
                VideoCommentId    = vm.VideoCommentId,
                AuthorDisplayName = user.NickName.Trim(),
                UserId            = user.Id,
                RepliedTo         = vm.AuthorDisplayName,
                IPAddress         = ipAddress,
                //Country = countryCode,
                IsSharer = await CheckSharer(user, vm.VideoPostId)
            };

            await _vcrRepository.AddAsync(newVideoCommentReply);

            await _vcrRepository.CommitAsync();

            var videoCommentReplyVM = Mapper.Map <VideoCommentReply, VideoCommentReplyVM>(newVideoCommentReply);

            return(CreatedAtRoute("GetVideoCommentReply", new
            {
                controller = "CardDetail",
                id = videoCommentReplyVM.VideoCommentReplyId
            }, videoCommentReplyVM));
        }