コード例 #1
0
        private string ValidateActPermission(string _objRole, ref List <TActionPermission> obj)
        {
            List <string> errMessage = new List <string>();

            try
            {
                obj = JsonConvert.DeserializeObject <List <TActionPermission> >(_objRole);
            }
            catch (Exception e)
            {
                _logger.ERROR(e.Message);
                errMessage.Add("Object ActionPermission can't be empty");
            }

            if (obj.Count == 0)
            {
                errMessage.Add("Please input at least 1 data");
            }
            else
            {
                foreach (var s in obj)
                {
                    if (string.IsNullOrEmpty(s.ActionName))
                    {
                        errMessage.Add("Some action name is empty");
                        break;
                    }
                }
            }
            return(string.Join(" \n ", errMessage));
        }
コード例 #2
0
        public IActionResult SubmitAdd(string obj)
        {
            MRole  obj_   = new MRole();
            string errMsg = Validate(obj, ref obj_);

            if (errMsg == "")
            {
                bool isExist = rlm.CheckIsExist(obj_.RoleID, ref errMsg);
                if (errMsg == "")
                {
                    errMsg = isExist ? "Data already exist" : "";
                }
                else
                {
                    logger_.ERROR(errMsg);
                    errMsg = "Internal Server Error";
                }
            }
            if (errMsg == "")
            {
                errMsg = rlm.Add(obj_);
                if (!string.IsNullOrEmpty(errMsg))
                {
                    logger_.ERROR(errMsg);
                    errMsg = "Internal Server Error";
                }
            }
            return(Z_Result.SetResult(errMsg));
        }
コード例 #3
0
        public IActionResult SubmitAdd(string obj)
        {
            MMenu  obj_   = new MMenu();
            string errMsg = Validate(obj, ref obj_);

            if (errMsg == "")
            {
                obj_.ID = obj_.ID.ToUpper();
                bool isDuplicate = mmgr.CheckIsExist(obj_.ID, ref errMsg);
                if (errMsg == "")
                {
                    errMsg = isDuplicate ? "Data Already Exist" : "";
                }
                else
                {
                    _logger.ERROR(errMsg);
                    errMsg = "Internal Server Error";
                }
            }

            if (errMsg == "")
            {
                errMsg = mmgr.Add(obj_);
                if (!string.IsNullOrEmpty(errMsg))
                {
                    _logger.ERROR(errMsg);
                    errMsg = "Internal Server Error";
                }
            }

            return(Z_Result.SetResult(errMsg));
        }
コード例 #4
0
        public IActionResult Error()
        {
            var exceptionFeature = HttpContext.Features.Get <IExceptionHandlerPathFeature>();

            if (exceptionFeature != null)
            {
                ZLogger objLog = _logger.GetLogInfo;
                objLog.Path = exceptionFeature.Path;
                _logger.SetLogInfo(objLog);
                _logger.ERROR(exceptionFeature.Error.Message);
            }
            //TODO create error view
            return(Z_Result.SetResult("Internal Server Error", new ErrorViewModel {
                RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
            }));
        }