예제 #1
0
        /// <summary>
        /// Returns the standard JSON response model indicating success, along with optionally the model specified as the data.
        /// </summary>
        public JsonNetResult JsonSuccess(object model = null)
        {
            var standardModel = new JsonResultViewModel
            {
                Success = true,
                Data    = model
            };

            return(JsonNetResult.New(standardModel));
        }
예제 #2
0
        /// <summary>
        /// Returns the standard JSON response model indicating failure, copying any ModelState errors to the Messages collection.
        /// </summary>
        public JsonNetResult JsonFailure()
        {
            IEnumerable <UiMessageViewModel> messages = ModelState.GetErrorUiMessages();

            var standardModel = new JsonResultViewModel
            {
                Success  = false,
                Messages = new List <UiMessageViewModel>(messages)
            };

            return(JsonNetResult.New(standardModel));
        }