Exemple #1
0
        //
        // GET: /Test/

        public ActionResult Index()
        {
            //string format="<p style='text-align: center; '>   <a href='http://www.ishayou.com/wp-content/uploads/2016/07/kiy7.png'><img class='alignnone size-full wp-image-1086' src=\"/wp-content/uploads/2016/07/kiy7.png\" alt='kiy7' width='1000' height='600' style='width: 721px; height: 514px;'/></a></p>";
            //string str = QIQU.Tools.CommonCs.GetImageSrc(format);

            //return Content(str);


            string theIP = "222.211.22.245"; //BaiduIPAdressAPI.GetHostAddress();
            string msg   = BaiduIPAdressAPI.GetInfoByUrl(BaiduIPAdressAPI.GetPostUrl(theIP));

            msg = System.Text.RegularExpressions.Regex.Unescape(msg);
            return(Content(msg));
        }
Exemple #2
0
        public int Add(FeedBack model, out string error)
        {
            error = "";
            if (model == null || string.IsNullOrEmpty(model.Title) || string.IsNullOrEmpty(model.Contents))
            {
                error = "内容不能为空";
                return(0);
            }

            if (model.Title.Length > 50 || model.Contents.Length > 300)
            {
                error = "反馈内容的字数超过范围";
                return(0);
            }

            string     ip     = CommonCs.GetHostAddress();
            t_feedback entity = new t_feedback()
            {
                contents    = model.Contents,
                title       = model.Title,
                from_ip     = ip,
                from_area   = BaiduIPAdressAPI.GetAddress(ip),
                create_time = DateTime.Now,
                status      = FeedBackStatus.Unread,
            };

            try
            {
                dbContext.t_feedback.Add(entity);
                dbContext.SaveChanges();


                return(1);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(0);
            }
        }
Exemple #3
0
        /// <summary>
        /// 添加评论
        /// </summary>
        /// <param name="model"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public ArticleComments AddComment(ArticleComment model, out string error)
        {
            error = "";
            if (model == null)
            {
                error = "评论模型不能为空";
                return(null);
            }
            if (model.ArticleId <= 0)
            {
                error = "参数错误";
                return(null);
            }
            if (string.IsNullOrEmpty(model.Contents))
            {
                error = "评论内容不能为空";
                return(null);
            }
            if (model.Contents.Length > 200)
            {
                error = "评论字数只能在200字以内";
                return(null);
            }

            string             ip     = CommonCs.GetIP();
            t_article_comments entity = new t_article_comments()
            {
                article_id = model.ArticleId,
                contents   = model.Contents,
                parent_id  = model.ParentId,
                user_id    = model.UserId,
                from_ip    = ip,
                from_area  = BaiduIPAdressAPI.GetAddress(ip),

                child_count = 0,
                status      = CommentStatus.Show,
                create_time = DateTime.Now,
            };

            try
            {
                dbContext.t_article_comments.Add(entity);
                dbContext.SaveChanges();

                #region 更新文章评论数,更新评论回复数

                if (entity.id > 0)//表示添加评论成功
                {
                    //更新文章评论数
                    if (entity.article_id > 0)
                    {
                        this.UpdateArticleCommentCount(entity.article_id);
                    }

                    //更新评论回复数
                    if (entity.parent_id > 0)
                    {
                        this.UpdateCommentCount(entity.parent_id);
                    }
                }


                #endregion

                return(new ArticleComments()
                {
                    ArticleId = entity.article_id,
                    ChildCount = entity.child_count,
                    CommentId = entity.id,
                    Contents = entity.contents,
                    CreateTime = entity.create_time,
                    FromArea = entity.from_area,
                    UserId = entity.user_id,
                    UserImage = base.defaultUserImgUrl,
                    UserName = "******",
                });
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(null);
            }
        }