private void addChildren(CreateOrganizationUnitDto node, int count)
 {
     Enumerable.Range(1, count)
     .ToList()
     .Select(x =>
     {
         return(new CreateOrganizationUnitDto()
         {
             DisplayName = node.DisplayName + "-Child-" + x, Children = new List <CreateOrganizationUnitDto>()
         });
     })
     .ToList()
     .ForEach(x => node.Children.Add(x));
 }
        private CreateOrganizationUnitDto createTestData()
        {
            //var rootId = _guidGenerator.Create();
            var root = new CreateOrganizationUnitDto()
            {
                DisplayName = "Root", Children = new List <CreateOrganizationUnitDto>()
            };

            addChildren(root, 10);
            root.Children.ToList()
            .ForEach(c =>
            {
                addChildren(c, 5);
            });
            return(root);
        }
        public async Task <OrganizationUnitDto> CreateOuInTenantAsync(CreateOrganizationUnitDto input)
        {
            using (CurrentUnitOfWork.SetTenantId(input.TenantId))
            {
                if (string.IsNullOrEmpty(input.Code))
                {
                    input.Code = await _organizationUnitManager.GetNextChildCodeAsync(input.ParentId);
                }

                OrganizationUnit entity = ObjectMapper.Map <OrganizationUnit>(input);

                //await _organizationUnitManager.CreateAsync(entity);

                long id = await _orgUnitRepository.InsertAndGetIdAsync(entity);

                entity.Id = id;

                return(ObjectMapper.Map <OrganizationUnitDto>(entity));
            }
        }
예제 #4
0
 public async Task Create(CreateOrganizationUnitDto input)
 {
     var organizationUnit = ObjectMapper.Map <OrganizationUnit>(input);
     await _organizationManager.CreateAsync(organizationUnit);
 }