示例#1
0
        public ActionResult ArticleFormPartial(ArticleCommentDto model)
        {
            var result = new QsResult();

            if (!Request.IsAjaxRequest())
            {
                return(new EmptyResult());
            }
            model.CreateTime = DateTime.Now;
            model.UniqueKey  = Utilities.GetRamCodeOnDate();
            if (System.Web.HttpContext.Current.Request.IsAuthenticated)
            {
                var curUser = CustomAuthorizeAttribute.GetUser();
                if (curUser.UserId == model.IsMember)
                {
                    if (ModelState.IsValid)
                    {
                        //result.Success = true;
                        //result.Message = @"用户登陆状态下验证成功";
                        _commentService.AddArticleComment(model);
                        var newModel = _commentService.GetNewestCommentInArticleWithFilter(model.UniqueKey);
                        return(PartialView("_SegmentPartial", newModel));
                    }
                    result.Success = false;
                    result.Message = @"用户登陆状态下验证失败~~";
                    return(Json(result));
                }
                result.Success = false;
                result.Message = @"用户的编号在客户端被修改,导致内容不一致";
                return(Json(result));
            }
            if (ModelState.IsValid)
            {
                //result.Success = true;
                //result.Message = @"游客状态下验证成功";
                //return Json(result);
                if (String.IsNullOrEmpty(model.NickName))
                {
                    model.NickName = @"[匿名用户]";
                }
                _commentService.AddArticleComment(model);
                var newModel = _commentService.GetNewestCommentInArticleWithFilter(model.UniqueKey);
                return(PartialView("_SegmentPartial", newModel));
            }
            result.Success = false;
            result.Message = @"游客状态下验证失败";
            return(Json(result));
        }