예제 #1
0
 protected ActionResult JsonOnFormPost(bool success, string partialViewName, object model)
 {
     return(Json(new
     {
         success = success,
         html = PartialConverter.PartialViewToString(this, partialViewName, model)
     }));
 }
예제 #2
0
 public IEnumerable <Expression> ConvertTokensToExpressions(IEnumerable <object> tokens)
 {
     tokens = CommentAndLayoutConverter.Convert(tokens);
     tokens = LiteralConverter.Convert(tokens);
     tokens = HelperConverter.Convert(tokens, _configuration);
     tokens = HashParametersConverter.Convert(tokens);
     tokens = PathConverter.Convert(tokens);
     tokens = SubExpressionConverter.Convert(tokens);
     tokens = PartialConverter.Convert(tokens);
     tokens = HelperArgumentAccumulator.Accumulate(tokens);
     tokens = ExpressionScopeConverter.Convert(tokens);
     tokens = WhitespaceRemover.Remove(tokens);
     tokens = StaticConverter.Convert(tokens);
     tokens = BlockAccumulator.Accumulate(tokens, _configuration);
     return(tokens.Cast <Expression>());
 }
예제 #3
0
        public ActionResult Ban(string commentId, string articleId)
        {
            bool   success = true;
            string html    = "";

            if (commentId != null && articleId != null)
            {
                DataServiceMessage <IEnumerable <BanReasonListDTO> > serviceMessage = banReasonService.GetEnabled();

                string partialViewName = serviceMessage.Succeeded
                    ? "Ban"
                    : "~/Views/Shared/Error.cshtml";
                object model = serviceMessage.Succeeded
                    ? new CommentBanViewModel
                {
                    Id         = commentId,
                    ArticleId  = articleId,
                    BanReasons = GetSelectListItems(serviceMessage.Data)
                } as object
                    : serviceMessage.Errors;

                success = serviceMessage.Succeeded;
                html    = PartialConverter.PartialViewToString(this, partialViewName, model);
            }
            else
            {
                success = false;
                html    = "Comment or article were not identified";
            }

            return(Json(new
            {
                success = success,
                html = html
            }, JsonRequestBehavior.AllowGet));
        }