예제 #1
0
        public static JsonResultExtension ExtjsFromJsonResult(this Controller c, bool isSuccess, ValidationResultCollection ValidationResultCollection = null, List <string> msg = null)
        {
            JsonResultExtension result = new JsonResultExtension();

            if (ValidationResultCollection != null && ValidationResultCollection.Count != 0)
            {
                Dictionary <string, string> dictionary = new Dictionary <string, string>();
                foreach (var item in ValidationResultCollection)
                {
                    dictionary.Add(item.MemberNames.First(), item.ErrorMessage);
                }
                result.Errors = dictionary;
            }
            else
            {
                result.Errors = null;
            }
            result.ExtjsUiSerialize = true;
            result.Success          = isSuccess;
            string msgs = "";

            if (msg != null)
            {
                foreach (var message in msg)
                {
                    msgs += message + "<br/>";
                }
            }
            result.Msg = msgs;
            return(result);
        }
예제 #2
0
        public static JsonResultExtension ValidateJsonResult(this Controller c, bool isSuccess,
                                                             ValidationResultCollection validationResultCollection = null, List <string> msg = null)
        {
            JsonResultExtension result = new JsonResultExtension {
                ExtjsUiSerialize = true, Success = isSuccess
            };
            string msgs = "";

            if (msg != null)
            {
                foreach (var message in msg)
                {
                    msgs += message + ";";
                }
            }
            if (validationResultCollection != null && validationResultCollection.Count != 0)
            {
                foreach (var item in validationResultCollection)
                {
                    msgs += item.ErrorMessage + ";";
                }
            }
            result.Msg = msgs;
            return(result);
        }
예제 #3
0
        public static JsonResultExtension ExtjsGridJsonResult(this Controller c, object data, long total)
        {
            dynamic             errors = new System.Dynamic.ExpandoObject();
            JsonResultExtension result = new JsonResultExtension
            {
                ExtjsUiSerialize = true,
                Success          = true,
                Total            = total,
                Data             = data
            };

            return(result);
        }
예제 #4
0
        public static JsonResultExtension ExtjsJsonResult(this Controller c, bool isSuccess, object data = null, List <string> msg = null)
        {
            JsonResultExtension result = new JsonResultExtension {
                ExtjsUiSerialize = true
            };
            string msgs = "";

            if (msg != null)
            {
                msgs = msg.Aggregate(msgs, (current, message) => current + (message + "<br/>"));
            }
            result.Msg     = msgs;
            result.Success = isSuccess;
            result.Data    = data;
            return(result);
        }