Пример #1
0
        public Result Remove(string key)
        {
            const string sql = "UPDATE [Base_DataItem] SET IsDel=1 WHERE K=@K";
            var          row = db.Execute(sql, new { K = key });

            if (row > 0)
            {
                DataItemUtil.Clear();
            }
            return(row > 0 ? ResultUtil.Success(row) : ResultUtil.Do(ResultCodes.数据库操作失败));
        }
Пример #2
0
        public Result Update(string key, string value, IAppUser user)
        {
            const string sql = "UPDATE [Base_DataItem] SET V=@V,UpdateAt=GETDATE(),UpdateBy=@UserId,Updator=@UserName WHERE K=@K";
            var          row = db.Execute(sql, new { K = key, V = value, UserId = user.Id, UserName = user.Name });

            if (row > 0)
            {
                DataItemUtil.Clear();
            }
            return(row > 0 ? ResultUtil.Success(row) : ResultUtil.Do(ResultCodes.数据库操作失败));
        }
Пример #3
0
        public override Result <int> Create(DataItem entity, IAppUser user)
        {
            var error = ValidCreate(entity, user);

            if (!string.IsNullOrWhiteSpace(error))
            {
                return(ResultUtil.Do(ResultCodes.验证失败, 0, "键已存在"));
            }

            entity.BeforeCreate(user);
            var row = db.Create(entity);

            if (row > 0)
            {
                DataItemUtil.Clear();
            }
            return(row > 0 ? ResultUtil.Success(row) : ResultUtil.Do(ResultCodes.数据库操作失败, 0));
        }