Ejemplo n.º 1
0
        public ActionResult Add(PresentView present)
        {
            int code = (int)ErrorMessage.失败;
            ComplexResponse <string> result;

            if (present.PropsId > 0 && present.PropsCount > 0)
            {
                //添加操作
                PresentView presentInfo = new PresentView();
                presentInfo            = GetLogInfo(presentInfo) as PresentView;
                presentInfo.UserId     = currentUser.UserId;
                presentInfo.UserName   = currentUser.UserName;
                presentInfo.NovelId    = present.NovelId;
                presentInfo.BindFee    = 0;
                presentInfo.Fee        = 0;
                presentInfo.FeeType    = 0;
                presentInfo.PropsCount = present.PropsCount;
                presentInfo.PropsId    = present.PropsId;

                int addResult = _presentService.Add(presentInfo);
                if (addResult == (int)ErrorMessage.成功)
                {
                    //ToDo
                    CommentView commentInfo = new CommentView();
                    commentInfo             = GetClientLogInfo(commentInfo) as CommentView;
                    commentInfo.AuthorId    = 0;
                    commentInfo.UserId      = currentUser.UserId;
                    commentInfo.UserName    = currentUser.UserName;
                    commentInfo.Message     = StringHelper.HtmlEncode(present.Message);
                    commentInfo.NovelId     = present.NovelId;
                    commentInfo.Status      = (int)Constants.Status.yes;
                    commentInfo.Creator     = "";
                    commentInfo.UpdateTime  = DateTime.Now;
                    commentInfo.AddTime     = DateTime.Now;
                    commentInfo.PropsId     = present.PropsId;
                    commentInfo.PropsCount  = present.PropsCount;
                    commentInfo.Title       = "";
                    commentInfo.Description = "";

                    _commentService.Send(commentInfo);
                }

                code = addResult;
            }
            else
            {
                code = (int)ErrorMessage.道具数量为0;
            }

            result = new ComplexResponse <string>(code);

            return(Json(result));
        }
Ejemplo n.º 2
0
        public virtual void OnAuthorization(AuthorizationContext filterContext)
        {
            #region

            if (IsAjaxOnly && !filterContext.HttpContext.Request.IsAjaxRequest())
            {
                filterContext.Result = new ContentResult {
                    Content = ""
                };
                return;
            }

            #endregion

            #region

            Host = StringHelper.GetHost(Host);
            GetUserInfo();

            #endregion

            if (!IsLogin())
            {
                switch (CType)
                {
                case ContentType.url:
                    string url = StringHelper.GetReturnUrl("/login", channelId: GetChannelId(filterContext, "channelId"));
                    filterContext.Result = new RedirectResult(url);
                    break;

                case ContentType.json:
                    var responseData = new ComplexResponse <string>(ErrorCode, Message, Content);
                    filterContext.Result = new JsonResult {
                        Data = responseData
                    };
                    break;

                case ContentType.str:
                    filterContext.Result = new ContentResult {
                        Content = Content
                    };
                    break;
                }
            }
        }