Ejemplo n.º 1
0
        public async Task MoveAsync(Guid id, Guid?parentId)
        {
            var entity = await _sysFileRepository.GetAsync(id);

            if (entity.ParentId == parentId)
            {
                return;
            }

            var children = await FindChildrenAsync(id, true);

            var oldCode = entity.Code;

            //开始移动

            entity.Code = await GetNextChildCodeAsync(parentId);

            entity.ParentId = parentId;
            // await ValidateSysfileAsync(entity);

            foreach (var child in children)
            {
                child.Code = SysFile.AppendCode(entity.Code, SysFile.GetRelativeCode(child.Code, oldCode));
            }
        }
Ejemplo n.º 2
0
        //// custom codes

        public virtual async Task <string> GetNextChildCodeAsync(Guid?parentId)
        {
            var lastChild = await GetLastChildOrNullAsync(parentId);

            if (lastChild == null)
            {
                var parentCode = parentId != null ? await GetCodeAsync(parentId.Value) : null;

                return(SysFile.AppendCode(parentCode, SysFile.CreateCode(1)));
            }

            return(SysFile.CalculateNextCode(lastChild.Code));
        }