public override Task <OrganizationUnitDto> Create(CreateOrganizationUnitDto input) { CheckCreatePermission(); var parent = Repository.Get(input.ParentId ?? "-2"); var entity = MapToEntity(input); if (parent != null) { entity.Path = parent.Path + parent.Id + ","; entity.PathName = parent.PathName + "," + entity.Name; } else { entity.PathName = entity.Name; } Repository.Insert(entity); if (IsGranted(PermissionNames.Pages_OrganizationUnits_SetRole)) { _organizationUnitManager.SetRole(input.Id, input.RoleIds); } if (IsGranted(PermissionNames.Pages_OrganizationUnits_SetPers)) { _organizationUnitManager.SetPermission(input.Id, input.PersIds); } return(Task.FromResult(MapToEntityDto(entity))); }