Exemplo n.º 1
0
        public JsonResult PostEditComments(ViewModels.CommentType ReplyType, string ID, string SiteID, string PosterName, string CommentContent)
        {
            CommentPostHandlerResult result = new CommentPostHandlerResult();
            long?  memberID = (long?)null;
            Member curUser  = Member.Current;

            if (ReplyType == ViewModels.CommentType.MemberOnly)
            {
                if (curUser == null)
                {
                    result.Result  = HandlerResult.MustLogin;
                    result.Message = "請先登入會員或會員登入時效已過期!";
                    return(Json(result));
                }
                memberID = curUser.ID;
            }
            if (curUser != null)
            {
                memberID = curUser.ID;
            }
            Models.PageCommentsModels comment = Models.DataAccess.PageCommentsDAO.GetSingleItem(long.Parse(SiteID), ID);
            comment.PosterName     = PosterName;
            comment.CommentContent = CommentContent;
            Models.DataAccess.PageCommentsDAO.SetItem(comment);
            result.Result  = HandlerResult.Success;
            result.Message = "儲存成功";
            return(Json(result));
        }
Exemplo n.º 2
0
        public JsonResult PostReplyComments(ViewModels.CommentType ReplyType, string PageSN, string Url, long ParentID, string PosterName, string CommentContent)
        {
            CommentPostHandlerResult result = new CommentPostHandlerResult();
            long?  memberID = (long?)null;
            Member curUser  = Member.Current;

            if (ReplyType == ViewModels.CommentType.MemberOnly)
            {
                if (curUser == null)
                {
                    result.Result  = HandlerResult.MustLogin;
                    result.Message = "請先登入會員或會員登入時效已過期!";
                    return(Json(result));
                }
                memberID = curUser.ID;
            }
            if (curUser != null)
            {
                memberID = curUser.ID;
            }
            if (ReplyType == ViewModels.CommentType.FB ||
                ReplyType == ViewModels.CommentType.Closed)
            {
                result.Result  = HandlerResult.NotSupport;
                result.Message = "系統不提供回文功能!";
                return(Json(result));
            }
            if (Models.DataAccess.PageCommentsDAO.IsPostCommentOverTime(PageSN, memberID))
            {
                result.Result  = HandlerResult.NoRepeat;
                result.Message = "您已「回文」過!";
                return(Json(result));
            }
            Models.PageCommentsModels comment = new Models.PageCommentsModels();
            comment.ID             = WorkLib.GetItem.NewSN();
            comment.PageSN         = PageSN;
            comment.ParentID       = ParentID;
            comment.PostDate       = DateTime.Now;
            comment.PosterName     = PosterName;
            comment.MemberShipID   = memberID;
            comment.ShowStatus     = true;
            comment.Title          = "Re:";
            comment.IP             = WorkLib.GetItem.IPAddr();
            comment.IPNum          = ((long)WorkLib.GetItem.GetIPNum()).ToString();
            comment.CommentContent = CommentContent;
            Models.DataAccess.PageCommentsDAO.SetItem(comment);
            result.Result  = HandlerResult.Success;
            result.Message = "回覆成功";
            return(Json(result));
        }
Exemplo n.º 3
0
        public PartialViewResult Index(ViewModels.PageCommentViewModel PageComment, string PageSN, string Url, string PosterName, string CommentContent)
        {
            long?memberID = (long?)null;

            if (PageComment.ReplyType == ViewModels.CommentType.MemberOnly)
            {
                Member curUser = Member.Current;
                if (curUser == null)
                {
                    //RedirectToAction("Index", "Home", new { siteSn = PageCache.SiteSN, pageSn = "Index" });
                    Response.Redirect(Url); //若不重導, 返回時, 它會呈現空白頁面, 暫時找不到解法.... charlie_shan 2018/02/20
                    return(PartialView("_PageComments", PageComment));
                }
                memberID = curUser.ID;
            }
            if (PageComment.ReplyType == ViewModels.CommentType.FB ||
                PageComment.ReplyType == ViewModels.CommentType.Closed)
            {
                //RedirectToAction("Index", "Home", new { siteSn = PageCache.SiteSN, pageSn = "Index" });
                Response.Redirect(Url); //若不重導, 返回時, 它會呈現空白頁面, 暫時找不到解法.... charlie_shan 2018/02/20
                return(PartialView("_PageComments", PageComment));
            }
            Models.PageCommentsModels comment = new Models.PageCommentsModels();
            comment.ID             = WorkLib.GetItem.NewSN();
            comment.PageSN         = PageSN;
            comment.PostDate       = DateTime.Now;
            comment.PosterName     = PosterName;
            comment.MemberShipID   = memberID;
            comment.ShowStatus     = true;
            comment.Title          = "";
            comment.IP             = WorkLib.GetItem.IPAddr();
            comment.IPNum          = ((long)WorkLib.GetItem.GetIPNum()).ToString();
            comment.CommentContent = CommentContent;
            Models.DataAccess.PageCommentsDAO.SetItem(comment);
            // ViewBag.Exit = true;
            Response.Redirect(Url); //若不重導, 返回時, 它會呈現空白頁面, 暫時找不到解法.... charlie_shan 2018/02/20
            return(PartialView("_PageComments", PageComment));
        }
Exemplo n.º 4
0
 public JsonResult GetSingleComment(string SiteID, string ID)
 {
     Models.PageCommentsModels item = Models.DataAccess.PageCommentsDAO.GetSingleItem(long.Parse(SiteID), ID);
     return(Json(item, JsonRequestBehavior.AllowGet));
 }