Beispiel #1
0
 /// <summary>
 /// 添加留言板的内容
 /// </summary>
 /// <param name="content"></param>
 /// <returns></returns>
 public ActionResult addLiuYan(string content = "")
 {
     if (content != null && content.Length > 0)
     {
         liuyanban model = new liuyanban()
         {
             content = content
         };
         if (Session["user"] != null)
         {
             var u = (user)Session["user"];
             model.uid   = (int)u.id;
             model.uname = u.nick_name;
         }
         else
         {
             model.uid   = 0;
             model.uname = "游客";
         }
         model.addtime = DateTime.Now;
         model.state   = 1;
         model.ip      = Tools.GetRealIP();
         return(Content(EfExt.insert(model).ToString()));
     }
     return(Content("0"));
 }
Beispiel #2
0
 public ActionResult edit_article(article model)
 {
     if (model != null && model.id > 0)
     {
         var r = EfExt.update(model);
         if (r > 0)
         {
             return(Content("修改成功"));
         }
     }
     return(Content("修改失败"));
 }
Beispiel #3
0
        /// <summary>
        /// 管理员在后台修改用户的资料
        /// </summary>
        /// <param name="u"></param>
        /// <returns></returns>
        public ActionResult updateUser(UserExt u)
        {
            if (u != null && u.id > 0)
            {
                if (u.id == 1 && (u.state == 0 || u.is_admin == false))
                {
                    return(Content("超级管理员的权限不能更改"));
                }

                var cur_user = (user)Session["user"];
                if (u.pwd != null && u.pwd.Length >= 6)
                {
                    if (u.id == 1 && cur_user.id != 1)
                    {
                        return(Content("超级管理员的密码不能更改"));
                    }
                    u.pwd = HashTools.SHA1_Hash(u.pwd);
                }
                else
                {
                    u.pwd = u.oldpwd;
                }

                if (u.email != null && u.email.Length > 0)
                {
                    if (u.reg_date == DateTime.MinValue)
                    {
                        return(Content("注册时间参数错误"));
                    }
                    reflectModel.setValues(u);
                    try
                    {
                        var model = reflectModel.AutoCopyToBase <user, UserExt>(u);
                        int res   = EfExt.Update(model);
                        if (res > 0)
                        {
                            return(Content("1"));
                        }
                    }
                    catch (Exception ex)
                    {
                        return(Content(ex.Message));
                    }

                    return(Content("修改失败"));
                }
                else
                {
                    return(Content("邮箱不能为空"));
                }
            }
            return(Content("参数错误"));
        }
Beispiel #4
0
 /// <summary>
 /// 修改发布文章的视图页
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult edit_art(int id = 0)
 {
     if (id > 0)
     {
         var m = EfExt.select <article>(id);
         if (m != null && m.id > 0)
         {
             ViewData["model"] = m;
             return(View());
         }
     }
     return(Content("无数据"));
 }
Beispiel #5
0
 /// <summary>
 /// 添加文章分类名称
 /// </summary>
 /// <param name="catename"></param>
 /// <returns></returns>
 public ActionResult addCategory(string catename = "")
 {
     if (catename != null && catename.Length > 0)
     {
         var r = EfExt.insert(new category()
         {
             category_name = catename
         });
         if (r > 0)
         {
             return(Content("1"));
         }
     }
     return(Content("添加失败"));
 }
Beispiel #6
0
 /// <summary>
 /// 更新分类名称
 /// </summary>
 /// <param name="id"></param>
 /// <param name="catename"></param>
 /// <returns></returns>
 public ActionResult updateCategory(int id = 0, string catename = "")
 {
     if (id > 0 && catename != null && catename.Length > 0)
     {
         var m = new category()
         {
             id = id, category_name = catename
         };
         var r = EfExt.update(m);
         if (r > 0)
         {
             return(Content("1"));
         }
     }
     return(Content("修改失败"));
 }
Beispiel #7
0
        /// <summary>
        /// 帖子审批
        /// </summary>
        /// <param name="model"></param>
        /// <param name="jbid">举报表的主键</param>
        /// <returns></returns>
        public ActionResult shenPiTieZi(TieZiExt model, int jbid = 0)
        {
            if (model != null && model.id > 0 && jbid > 0)
            {
                using (WeiQingEntities db = new WeiQingEntities())
                {
                    int res = 0;
                    var t   = db.tiezi.Where(x => x.id == model.id).FirstOrDefault();
                    if (t != null && t.id > 0)
                    {
                        t.state = model.state;

                        if (model.replyList != null && model.replyList.Count > 0)
                        {
                            var rlist = db.tzreply.Where(x => x.tzid == t.id).ToList();  // 获取帖子的回复列表
                            if (rlist != null && rlist.Count > 0)
                            {
                                var tempdic = model.replyList.ToDictionary(x => x.id);
                                foreach (var item in rlist)
                                {
                                    if (tempdic.ContainsKey(item.id))
                                    {
                                        item.state = tempdic[item.id].state;
                                    }
                                }
                                res += EfExt.UpdateMany(rlist);
                            }
                        }

                        var jb = db.tiezi_jubao.Where(x => x.id == jbid).FirstOrDefault();
                        if (jb != null && jb.id > 0 && jb.tzid == t.id)
                        {
                            jb.state = 1;   // 已审批
                            res     += db.SaveChanges();
                            if (res > 0)
                            {
                                return(Content("审核成功"));
                            }
                            return(Content("审核失败"));
                        }
                    }
                }
            }
            return(Content("参数错误"));
        }
Beispiel #8
0
 public ActionResult fbart(article model)
 {
     if (model != null)
     {
         reflectModel.setValues(model);
         if (model.content.Length > 0 && model.title.Length > 0)
         {
             model.addtime = DateTime.MinValue;
             var user = (user)Session["user"];
             model.uid = (int)user.id;
             if (EfExt.insert(model) > 0)
             {
                 return(Content("发布成功"));
             }
         }
     }
     return(Content("发布失败"));
 }
Beispiel #9
0
 /// <summary>
 /// 根据指定的文章id,查看文章
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult article(int id = 0)
 {
     if (id > 0)
     {
         try
         {
             var m = EfExt.select <article>(id);
             if (m != null && m.id > 0)
             {
                 ViewData["m"] = m;
                 return(View());
             }
         }
         catch (Exception ex)
         {
             return(Content(ex.Message));
         }
     }
     return(Content("<script>alert('无数据');location.href='/index/index';</script>"));
 }
Beispiel #10
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public ActionResult category()
 {
     ViewData["flList"] = EfExt.selectAll <category>();
     return(View());
 }