public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("HttpError404", "Error"));
            }
            var role = _roles.GetRole((int)id);

            if (role == null)
            {
                return(RedirectToAction("HttpError404", "Error"));
            }
            return(View(role));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Add(VWModel.ArticleVModel model, string vercode)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new JsonResultModel {
                    Message = ModelStateHelper.GetAllErrorMessage(ModelState)
                }));
            }
            if (string.IsNullOrEmpty(vercode))
            {
                return(Json(new JsonResultModel {
                    Message = "请输入验证码!"
                }));
            }
            if (!VerCode.CheckVerifyCode(vercode))
            {
                return(Json(new JsonResultModel {
                    Message = "验证码错误,请重新输入!"
                }));
            }

            if (!ArticlesPublic.CheckCanPost(CurrentUserInfo.Id, Site.Config.UserConfig.AddArticleInterval))
            {
                return(Json(new JsonResultModel {
                    Message = "操作速度太快了,喝口水再试一下!"
                }));
            }
            model.UserId         = CurrentUserInfo.Id;
            model.LastEditUserId = CurrentUserInfo.Id;
            var user = Users.GetUserById(CurrentUserInfo.Id);

            if (user == null || user.IsNull)
            {
                return(Json(new JsonResultModel {
                    Message = "用户信息异常!"
                }));
            }
            var role = Roles.GetRole(user.RoleId);

            if (role == null || role.IsNull)
            {
                return(Json(new JsonResultModel {
                    Message = "角色信息异常!"
                }));
            }
            //根据角色判断是否需要审核
            model.State = (short)(role.ArticleNeedVerified?0:1);

            long id = await ArticlesPublic.Add(model);

            if (id <= 0)
            {
                return(Json(new JsonResultModel {
                    Message = "提交失败!"
                }));
            }
            await UserPublic.UpdateArticleNum(CurrentUserInfo.Id, 1);

            return(Json(new JsonResultModel {
                ResultState = true, Message = "发表成功!", Action = Url.Action("Detail", "Article", new{ aid = id })
            }));
        }
Exemplo n.º 3
0
        public ActionResult Add(int id, string content)
        {
            if (id < 0)
            {
                return(Json(new JsonResultModel {
                    Message = "参数无效!"
                }));
            }
            if (string.IsNullOrEmpty(content) || content.Length < Site.Config.WebSysConfig.CommentMinLength)
            {
                return(Json(new JsonResultModel {
                    Message = "评论内容太短了!"
                }));
            }
            if (content.Length > Site.Config.WebSysConfig.CommentMaxLength)
            {
                return(Json(new JsonResultModel {
                    Message = "评论内容太长了!"
                }));
            }
            if (!CommentsPublic.CheckCanPost(CurrentUserInfo.Id, Site.Config.UserConfig.AddCommentInterval))
            {
                return(Json(new JsonResultModel {
                    Message = "操作速度太快了,喝口水再试一下!"
                }));
            }
            var articles = Articles.GetArticleInfoById(id);

            if (articles.IsCloseComment)
            {
                return(Json(new JsonResultModel {
                    Message = string.Format("评论已关闭!原因:{0}", articles.CloseCommentReason)
                }));
            }
            var comment = new CommentVModel()
            {
                UserId    = CurrentUserInfo.Id,
                AId       = id,
                IP        = Common.Fetch.Ip,
                Content   = content,
                UserAgent = Common.Fetch.UserAgent
            };
            var user = Users.GetUserById(CurrentUserInfo.Id);

            if (user == null || user.IsNull)
            {
                return(Json(new JsonResultModel {
                    Message = "用户信息异常!"
                }));
            }
            var role = Roles.GetRole(user.RoleId);

            if (role == null || role.IsNull)
            {
                return(Json(new JsonResultModel {
                    Message = "角色信息异常!"
                }));
            }
            //根据角色判断是否需要审核
            comment.State = (short)(role.CommentNeedVerified ? 0 : 1);


            long cid = CommentsPublic.AddComment(comment);

            if (cid <= 0)
            {
                return(Json(new JsonResultModel {
                    Message = "评论失败!"
                }));
            }
            return(Json(new JsonResultModel <long> {
                ResultState = true, Message = "评论成功!", Body = cid
            }));
        }
Exemplo n.º 4
0
        public static RoleInfo GetRoleFull(int roleid)
        {
            IRoles dal = Snitz.Membership.Helpers.Factory <IRoles> .Create("Role");

            return(dal.GetRole(roleid));
        }