public void GetIpTest()
        {
            var ip = IpService.GetPublicIp();

            _testOutputHelper.WriteLine(ip);
            Assert.NotNull(ip);
        }
Beispiel #2
0
        public async Task <IActionResult> Add(string content, string user, string comment, string article)
        {
            string ip = _accessor.HttpContext.Connection.RemoteIpAddress.ToString();
            //ip = "106.12.126.88";
            var address = await IpService.GetIpCity(ip);

            user = base._UserInfo.UserId;
            if (string.IsNullOrEmpty(user))
            {
                return(ErrRes("请先登陆"));
            }

            var commentModel = await _unitOfWork.SysCmsInfoCommentRepository.GetAsync(comment);

            SysCmsInfoComment sysCmsInfoComment = new SysCmsInfoComment
            {
                SysCmsInfoId        = article,
                SysCmsInfoCommentId = GuidKey,
                Ip          = ip,
                Status      = 1,
                Address     = address,
                Comment     = content,
                CommentTime = DateTime.Now,
                SysUserId   = user,
                ToCommentId = comment,
                UserLable   = user == "admin"?"1":"2",
            };
            var articleModel = await _unitOfWork.SysCmsInfoRepository.GetAsync(article);

            if (articleModel != null)
            {
                sysCmsInfoComment.SysCmsColumnId = articleModel.SysCmsColumnId;
                articleModel.InfoComments        = articleModel.InfoComments + 1;
            }
            if (commentModel != null)
            {
                sysCmsInfoComment.ToUserId = commentModel.SysUserId;
            }
            var result = _unitOfWork.SysCmsInfoCommentRepository.Insert(sysCmsInfoComment);

            if (articleModel != null)
            {
                result = _unitOfWork.SysCmsInfoRepository.Update(articleModel);
            }
            if (result)
            {
                if (string.IsNullOrEmpty(comment))
                {
                    var formartComment = _sysCmsInfoCommentService.GetComment(sysCmsInfoComment.SysCmsInfoCommentId);
                    return(SuccessRes(formartComment));
                }
                else
                {
                    var formartComment = _sysCmsInfoCommentService.GetReply(sysCmsInfoComment.SysCmsInfoCommentId);
                    return(SuccessRes(formartComment));
                }
            }
            return(ErrRes("添加留言失败失败"));
        }
Beispiel #3
0
        } // CreateKey

        public UiBroadcastService(IpService service, string providerDomainName)
        {
            if (service == null)
            {
                throw new ArgumentNullException("IpService service");
            }

            Data       = service;
            DomainName = (Data.TextualIdentifier.DomainName ?? providerDomainName).ToLowerInvariant();
            Key        = GetKey(service.TextualIdentifier, providerDomainName);
        } // constructor
Beispiel #4
0
 public IpController()
 {
     _ipService = new IpService();
 }