Exemple #1
0
        public JsonResult Manage(string mode, TModel[] models)
        {
            try {
                NgResult result;
                switch (mode)
                {
                case "cr":
                case "create":
                    result = _create(models);
                    break;

                case "up":
                case "update":
                    result = _update(models);
                    break;

                case "dl":
                case "delete":
                    result = _delete(models);
                    break;

                default:
                    result = NgResult.Fail(DEBS.Translate("MessageMdl.Undefined Manage mode: {0}", mode));
                    break;
                }
                return(NgResultToJsonResult(result));
            }
            catch {
#if EAT_EXCEPTIONS
                return(NgResultToJsonResult(NgResult.Fail("Internal Server Error")));
#else
                throw;
#endif
            }
        }
Exemple #2
0
        public JsonResult Fetch(int?Skip, int?Count, NgControllerInstruct[] filters)
        {
            try {
                var result = _fetch(Skip, Count, filters);
                return(NgResultToJsonResult(result));
            }
            catch {
#if EAT_EXCEPTIONS
                return(NgResultToJsonResult(NgResult.Fail("Internal Server Error")));
#else
                throw;
#endif
            }
        }
Exemple #3
0
 protected JsonResult NgResultToJsonResult(NgResult result)
 {
     return(result.successful ?
            MakeSuccesResult(result) :
            MakeBadRequest(result.message));
 }