Example #1
0
        public virtual JsonModel GetEntityById(int id)
        {
            JsonModel jsonModel = null;

            try
            {
                T entity = CurrentDal.GetEntityById(CurrentEntity, id);
                if (entity != null)
                {
                    jsonModel = new JsonModel()
                    {
                        errNum  = 0,
                        errMsg  = "success",
                        retData = entity
                    };
                }
                else
                {
                    jsonModel = new JsonModel()
                    {
                        errNum  = 999,
                        errMsg  = "获取数据失败",
                        retData = null
                    };
                }

                return(jsonModel);
            }
            catch (Exception ex)
            {
                jsonModel = new JsonModel()
                {
                    errNum  = 400,
                    errMsg  = ex.Message,
                    retData = ""
                };
                return(jsonModel);
            }
        }