Exemplo n.º 1
0
        //<---------------------------------新增留言---------------------------->
        public JsonResult CreateComment(int MemberID, string Main, int ArticleID)
        {
            tComment list = new tComment()
            {
                MemberID  = MemberID,
                Main      = Main,
                ArticleID = ArticleID,
                UpTime    = DateTime.Now,
            };

            tc.create(list);

            return(Json(tc.getAll().LastOrDefault(t => t.No > 0).No, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        //<---------------------------------顯示回文留言---------------------------->
        public JsonResult ReComment()
        {
            var list = trc.getAll().Select(m => new
            {
                MemberName  = tm.getAll().FirstOrDefault(t => t.MemberID == m.MemberID).MemberName,
                Main        = m.Main,
                UpTime      = m.UpTime,
                MemberID    = m.MemberID,
                ReArticleID = m.ReArticleID,
                ImgURL      = tm.getAll().FirstOrDefault(t => t.MemberID == m.MemberID).ImgURL,
                No          = m.No,
            });

            return(Json(list, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        //<---------------------------------新增文章---------------------------->
        public JsonResult CreateDiscuss(tArticle form)
        {
            tArticle list = new tArticle()
            {
                Category  = form.Category,
                Title     = form.Title,
                Main      = form.Main,
                UpTime    = DateTime.Now,
                LoveCount = 0,
                ViewCount = 0,
                MemberID  = form.MemberID
            };

            ta.create(list);
            var ID = ta.getAll().LastOrDefault(m => m.ArticleID > 0).ArticleID;

            return(Json(ID, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        //<-----------------登入--------------------->
        public string Login(string Account, string Password, bool RememberMe)
        {
            string result;

            if (tm.getAll().FirstOrDefault(m => m.Account == Account && m.Password == Password) != null)
            {
                if (tm.getAll().FirstOrDefault(m => m.Account == Account).Status == 1)
                {
                    Response.Cookies["AutoLogin"]["MemberID"]   = tm.getAll().FirstOrDefault(m => m.Account == Account).MemberID.ToString();
                    Response.Cookies["AutoLogin"]["MemberName"] = tm.getAll().FirstOrDefault(m => m.Account == Account).MemberName.ToString();
                    result = "登入成功";
                    if (RememberMe)
                    {
                        Response.Cookies["AutoLogin"].Expires = DateTime.Now.AddMonths(1);
                    }
                }
                else
                {
                    result = "帳號已被封鎖 或 尚未啟用請確認信箱";
                }
            }
            else
            {
                result = "帳號密碼錯誤";
            }
            return(result);
        }
Exemplo n.º 5
0
        //<---------------------------------刪除文章---------------------------->
        public JsonResult DelDiscuss(int ArticleID)
        {
            var count = tra.getAll().Where(m => m.ArticleID == ArticleID).Count();                     //抓到回文數

            for (int i = 0; i < count; i++)
            {
                var raid   = tra.getAll().FirstOrDefault(m => m.ArticleID == ArticleID).ReArticleID;
                var count1 = trc.getAll().Where(m => m.ReArticleID == raid).Count();
                for (int k = 0; k < count1; k++)
                {
                    trc.delete(trc.getAll().FirstOrDefault(m => m.ReArticleID == raid).No);           //殺回文留言
                }

                var count2 = tral.getAll().Where(m => m.ReArticleID == raid).Count();
                for (int k = 0; k < count2; k++)
                {
                    tral.delete(tral.getAll().FirstOrDefault(m => m.ReArticleID == raid).No);        //殺回文愛心
                }
                tra.delete(tra.getAll().FirstOrDefault(m => m.ArticleID == ArticleID).ReArticleID);  //殺回文
            }

            var ccount = tc.getAll().Where(m => m.ArticleID == ArticleID).Count();

            for (int i = 0; i < ccount; i++)
            {
                tc.delete(tc.getAll().FirstOrDefault(m => m.ArticleID == ArticleID).No);            //殺本文留言
            }

            var ccount1 = tal.getAll().Where(m => m.ArticleID == ArticleID).Count();

            for (int i = 0; i < ccount1; i++)
            {
                tal.delete(tal.getAll().FirstOrDefault(m => m.ArticleID == ArticleID).No);          //殺本文愛心
            }
            ta.delete(ArticleID);                                                                   //殺本文
            return(Json("", JsonRequestBehavior.AllowGet));
        }