Exemplo n.º 1
0
        /// <summary>
        /// 添加评论
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> AddDiscuss(ArticleCommentDto data)
        {
            var userHostAddress = Request.HttpContext.Connection.RemoteIpAddress?.ToString();
            var ipaddress       = userHostAddress.Replace("::ffff:", "");

            data.Ip          = ipaddress == "::1" ? null : ipaddress;
            data.CommentTime = DateTime.Now;
            bool result = await _service.AddDiscuss(data);

            return(Json(new { code = result, msg = result ? "发表成功" : "发表失败" }));
        }