コード例 #1
0
        public JsonResult delComment(comment comment)
        {
            User user = (User)Session["user"];

            if (user != null)
            {
                if (user.type == 1)
                {
                    DbNewsDataContext db = new DbNewsDataContext();
                    var query            = from t in db.comment
                                           where t.id == comment.id
                                           select t;
                    foreach (comment item in query)
                    {
                        db.comment.DeleteOnSubmit(item);
                    }
                    db.SubmitChanges();
                    return(Json(Result.success()));
                }
                else
                {
                    return(Json(Result.fail()));
                }
            }
            else
            {
                return(Json(Result.fail()));
            }
        }
コード例 #2
0
        public JsonResult addNews(news news)
        {
            User user = (User)Session["user"];

            if (user != null)
            {
                if (user.type == 1)
                {
                    news.userId = user.id;
                    news.date   = DateTime.Now;
                    DbNewsDataContext db = new DbNewsDataContext();
                    db.news.InsertOnSubmit(news);
                    db.SubmitChanges();
                    return(Json(Result.success()));
                }
                else
                {
                    return(Json(Result.fail()));
                }
            }
            else
            {
                return(Json(Result.fail()));
            }
        }
コード例 #3
0
        public JsonResult addUser(user requestData)
        {
            requestData.nickname = requestData.username;
            requestData.type     = 0;
            DbNewsDataContext db = new DbNewsDataContext();

            db.user.InsertOnSubmit(requestData);
            db.SubmitChanges();
            return(Json(Result.success()));
        }
コード例 #4
0
        public JsonResult addComment(comment comment)
        {
            User user = (User)Session["user"];

            if (user != null)
            {
                comment.userId = user.id;
                comment.status = 0;
                comment.date   = DateTime.Now;
                DbNewsDataContext db = new DbNewsDataContext();
                db.comment.InsertOnSubmit(comment);
                db.SubmitChanges();
                return(Json(Result.success()));
            }
            else
            {
                return(Json(Result.fail()));
            }
        }
コード例 #5
0
        public JsonResult setUserPassword(User requestData)
        {
            User user = (User)Session["user"];

            if (user != null)
            {
                DbNewsDataContext db = new DbNewsDataContext();
                var query            = from t in db.user
                                       where t.id == user.id
                                       select t;
                foreach (user item in query)
                {
                    item.password = requestData.password;
                    db.SubmitChanges();
                }
                return(Json(Result.success()));
            }
            else
            {
                return(Json(Result.fail()));
            }
        }
コード例 #6
0
        public JsonResult addCategory(category category)
        {
            User user = (User)Session["user"];

            if (user != null)
            {
                if (user.type == 1)
                {
                    DbNewsDataContext db = new DbNewsDataContext();
                    db.category.InsertOnSubmit(category);
                    db.SubmitChanges();
                    return(Json(Result.success()));
                }
                else
                {
                    return(Json(Result.fail()));
                }
            }
            else
            {
                return(Json(Result.fail()));
            }
        }