Пример #1
0
        protected virtual async Task UpdateOrganizeAsync(CreateOrUpdateOrganizeInput input)
        {
            Debug.Assert(input.Organize.Id != null, "input.Organize.Id should be set.");

            var organize = input.Organize.MapTo<AuthorityOrganizeInfo>();

            var oldParentId = _organizeRepository.FirstOrDefault(organize.Id).ParentId;
            if (oldParentId == organize.ParentId)
            {
                organize.FullPathName = organize.FullPathName.Substring(0, organize.FullPathName.LastIndexOf('\\') + 1) + organize.ShortName;
            }
            else//修改父节点
            {
                var parentOrganize = _organizeRepository.FirstOrDefault(organize.ParentId);
                if (parentOrganize != null)
                {
                    organize.FullPathName = parentOrganize.FullPathName + @"\" + organize.ShortName;
                }
            }
            organize.LastModifierUserId = AbpSession.UserId;
            organize.LastModifierUserName = GetCurrentUser().RealName;
            organize.LastModificationTime = Clock.Now;
            await _organizeRepository.UpdateAsync(organize);
            cacheHandler.Remove(CacheCategoryOrganize, "GetOrganizeList");
        }
Пример #2
0
 protected virtual async Task CreateOrganizeAsync(CreateOrUpdateOrganizeInput input)
 {
     var organize = input.Organize.MapTo<AuthorityOrganizeInfo>();
     if (organize.ParentId != Guid.Empty)
     {
        var parentOrganize=_organizeRepository.FirstOrDefault(organize.ParentId);
        if (parentOrganize != null)
        {
            organize.FullPathName = parentOrganize.FullPathName + @"\" + organize.ShortName;
        }
     }
     else
     {
         organize.FullPathName = organize.ShortName;
     }
     organize.Id = GuidHelper.NewGuid();
     organize.CreatorUserId = AbpSession.UserId;
     organize.CreatorUserName = GetCurrentUser().RealName;
     organize.CreationTime = Clock.Now;
     await _organizeRepository.InsertAsync(organize);
     cacheHandler.Remove(CacheCategoryOrganize, "GetOrganizeList");
 }
Пример #3
0
 /// <summary>
 /// 添加修改实体
 /// </summary>
 /// <param name="input"></param>
 /// <returns></returns>
 public async Task CreateOrUpdateOrganize(CreateOrUpdateOrganizeInput input)
 {
     if (input.Organize.Id != null && input.Organize.Id != Guid.Empty)
     {
         await UpdateOrganizeAsync(input);
     }
     else
     {
         await CreateOrganizeAsync(input);
     }
 }