コード例 #1
0
 public ActionResult Index(FormCollection collection)
 {
     try
     {
         var comment = new ArticleUserComment();
         RadynTryUpdateModel(comment, collection);
         PredicateBuilder <ArticleUserComment> query = new PredicateBuilder <ArticleUserComment>();
         query.And(x => x.ArticleId == comment.ArticleId);
         if (!string.IsNullOrEmpty(collection["NameOfUser"]))
         {
             query.And(x => x.Name.Contains(collection["Name"]) || x.Name.Contains(collection["Name"]));
         }
         if (!string.IsNullOrEmpty(comment.SaveDate))
         {
             query.And(x => x.SaveDate == comment.SaveDate);
         }
         if (!string.IsNullOrEmpty(comment.SaveTime))
         {
             query.And(x => x.SaveTime == comment.SaveTime);
         }
         if (collection["ConfirmAdmin"] != "All")
         {
             query.And(x => x.ConfirmAdmin == comment.ConfirmAdmin);
         }
         var result = CongressComponent.Instance.BaseInfoComponents.ArticleUserCommentFacade.OrderByDescending(x => x.SaveDate + " " + x.SaveTime, query.GetExpression());
         return(PartialView("PVGetIndex", result));
     }
     catch (Exception ex)
     {
         ShowExceptionMessage(ex);
         return(Content("false"));
     }
 }
コード例 #2
0
 public ActionResult SetComment(FormCollection collection)
 {
     try
     {
         if (!Request.Url.Authority.Contains("localhost"))
         {
             var service = new CaptchaService();
             if (!service.IsValidCaptcha(collection["captch"]))
             {
                 SessionParameters.HasLoginPasswordError = true;
                 throw new Exception(Resources.CommonComponent.Enterthesecuritycodeisnotvalid);
             }
         }
         var ip = WebUtility.GetClientIp();
         if (string.IsNullOrEmpty(collection["Name"]))
         {
             ShowMessage(Resources.Congress.PleaseEnterYourName, Resources.Common.MessaageTitle,
                         messageIcon: MessageIcon.Error);
             return(Content("false"));
         }
         if (string.IsNullOrEmpty(collection["Description"]))
         {
             ShowMessage(Resources.Congress.PleaseEnterYourComment, Resources.Common.MessaageTitle,
                         messageIcon: MessageIcon.Error);
             return(Content("false"));
         }
         var comment = CongressComponent.Instance.BaseInfoComponents.ArticleUserCommentFacade.FirstOrDefault(x => x.ArticleId == collection["ArticleId"].ToGuid() && x.IP == ip);
         if (comment == null || !string.IsNullOrEmpty(comment.Description))
         {
             comment = new ArticleUserComment()
             {
                 IP = ip
             };
             RadynTryUpdateModel(comment, collection);
             if (!CongressComponent.Instance.BaseInfoComponents.ArticleUserCommentFacade.Insert(comment))
             {
                 ShowMessage(Resources.Congress.ErrorInInsertComment, Resources.Common.MessaageTitle,
                             messageIcon: MessageIcon.Error);
                 return(Content("false"));
             }
         }
         else
         {
             RadynTryUpdateModel(comment, collection);
             if (!CongressComponent.Instance.BaseInfoComponents.ArticleUserCommentFacade.Update(comment))
             {
                 ShowMessage(Resources.Congress.ErrorInInsertComment, Resources.Common.MessaageTitle,
                             messageIcon: MessageIcon.Error);
                 return(Content("false"));
             }
         }
         return(Content("true"));
     }
     catch (Exception ex)
     {
         ShowExceptionMessage(ex);
         return(Content("false"));
     }
 }
コード例 #3
0
        public ActionResult SetComment(Guid articleId)
        {
            var comment = new ArticleUserComment()
            {
                ArticleId = articleId
            };

            return(View(comment));
        }
コード例 #4
0
        // GET: Congress/ArticleUserComment
        public ActionResult Index(Guid articleId)

        {
            var article = CongressComponent.Instance.BaseInfoComponents.ArticleFacade.Get(articleId);
            var comment = new ArticleUserComment()
            {
                ArticleId = articleId, Article = article
            };

            return(View(comment));
        }
コード例 #5
0
        public ActionResult SetLike(Guid articleId)
        {
            try
            {
                var ip      = WebUtility.GetClientIp();
                var comment = CongressComponent.Instance.BaseInfoComponents.ArticleUserCommentFacade.FirstOrDefault(x => x.ArticleId == articleId && x.IP == ip);
                if (comment != null)
                {
                    comment.IsLike = !comment.IsLike;

                    if (!CongressComponent.Instance.BaseInfoComponents.ArticleUserCommentFacade.Update(comment))
                    {
                        ShowMessage(Resources.Congress.ErrorInUpdateComments, Resources.Common.MessaageTitle,
                                    messageIcon: MessageIcon.Error);
                        return(Content("false"));
                    }
                }
                else
                {
                    comment = new ArticleUserComment()
                    {
                        IsLike = true, ArticleId = articleId, IP = ip
                    };
                    if (!CongressComponent.Instance.BaseInfoComponents.ArticleUserCommentFacade.Insert(comment))
                    {
                        ShowMessage(Resources.Congress.ErrorInUpdateComments, Resources.Common.MessaageTitle,
                                    messageIcon: MessageIcon.Error);
                        return(Content("false"));
                    }
                }

                return(Content("true"));
            }
            catch (Exception ex)
            {
                ShowExceptionMessage(ex);
                return(Content("false"));
            }
        }