Ejemplo n.º 1
0
        public string EXP_PostAdd(int TopicID, string Content)
        {
            timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            using (var db = new efwaskEntities())
            {
                try
                {
                    EXP_Post myexp_post = new EXP_Post();
                    myexp_post.UserID    = User.userid;
                    myexp_post.TopicID   = TopicID;
                    myexp_post.Replyer   = User.user_details.username;
                    myexp_post.RContent  = Content;
                    myexp_post.ReplyTime = DateTime.Now;
                    myexp_post.ReplyerIP = Utils.GetRealIP();
                    myexp_post.CaiNa     = "0";
                    myexp_post.isDel     = "0";
                    myexp_post.City      = "无锡";

                    db.EXP_Post.Add(myexp_post);
                    db.SaveChanges();
                    int ID = myexp_post.ID;
                    return(JsonConvert.SerializeObject(new repmsg {
                        state = 1, msg = "回答成功!", data = ID
                    }));
                }
                catch (Exception e)
                {
                    return(JsonConvert.SerializeObject(new repmsg {
                        state = 2, msg = "暂无记录,请稍后再试!", data = null
                    }));
                }
            }
        }
Ejemplo n.º 2
0
        public string EXP_TopicAdd(int M_ETID, string M_ETName, string Title, string Content, int ETID, string ETName, string albumArr)
        {
            timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            string guid = Guid.NewGuid().ToString();

            using (var db = new efwaskEntities())
            {
                try
                {
                    var exp_topic = new EXP_Topic
                    {
                        UserID     = User.userid,
                        M_ETID     = M_ETID,   //类别
                        M_ETName   = M_ETName, //类别名称
                        Title      = Title,
                        Content    = Content,
                        Author     = User.user_member.username,
                        Img        = guid,
                        UpdateTime = DateTime.Now,

                        Commend = "0",

                        ETID   = ETID,
                        ETName = ETName,

                        isDel = "0",
                        City  = "无锡"
                    };
                    db.EXP_Topic.Add(exp_topic);

                    //添加图片
                    if (albumArr != null && albumArr.Length > 0)
                    {
                        string[] imgArr = albumArr.Split('|');


                        for (int i = 0; i < imgArr.Length; i++)
                        {
                            var exp_topicimg = new EXP_TopicImg
                            {
                                topicid = guid,
                                imgurl  = imgArr[i]
                            };
                            db.EXP_TopicImg.Add(exp_topicimg);
                        }
                    }
                    db.SaveChanges();

                    return(JsonConvert.SerializeObject(new repmsg {
                        state = 1, msg = "回答成功!", data = null
                    }));
                }
                catch (Exception e)
                {
                    return(JsonConvert.SerializeObject(new repmsg {
                        state = 2, msg = "暂无记录,请稍后再试!", data = null
                    }));
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加点赞和收藏  http://192.168.1.223/GR_EXP_Topic/EXP_likeTopicAdd
        /// </summary>
        /// <param name="TopicID"></param>
        /// <param name="type">1点赞,2收藏</param>

        /// <returns></returns>
        public string EXP_likeTopicAdd(int TopicID, int type = 1)
        {
            timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            using (var db = new efwaskEntities())
            {
                try
                {
                    //判断有么有重复点赞或者收藏
                    int totalexp_liketopic = db.Database.SqlQuery <int>(@"select isnull(count(0),0)num  from EXP_likeTopic where  userid=@userid and TopicID=@TopicID and type=@type ",
                                                                        new SqlParameter[] { new SqlParameter("@userid", User.userid),
                                                                                             new SqlParameter("@TopicID", TopicID),
                                                                                             new SqlParameter("@type", type) }).First();

                    if (totalexp_liketopic > 0)
                    {
                        return(JsonConvert.SerializeObject(new repmsg {
                            state = 2, msg = "操作已成功,请勿重复提交!", data = null
                        }));
                    }

                    var exp_liketopic = new EXP_likeTopic
                    {
                        username = User.user_details.username,
                        topicid  = TopicID,
                        type     = type,
                        userid   = User.userid,
                    };
                    db.EXP_likeTopic.Add(exp_liketopic);
                    db.SaveChanges();
                    return(JsonConvert.SerializeObject(new repmsg {
                        state = 1, msg = "操作成功!", data = null
                    }));
                }
                catch (Exception e)
                {
                    return(JsonConvert.SerializeObject(new repmsg {
                        state = 2, msg = "暂无记录,请稍后再试!", data = null
                    }));
                }
            }
        }