0
carelearning created
Hello,
We have a business need to have duplicate Display Names in OrganizationUnits under the same parent. We have association metadata tables to differentiate between them. Is there a way to disable the check on save when using the IRepository<OrganizationUnit>? Currently we get the following error: "There is already an organization unit with name [name]. Two units with same name can not be created in same level." The documentation here does not mention this as a requirement.
Thank you for your time and effort.
3 Answer(s)
-
0
You can subclass OrganizationUnitManager to override ValidateOrganizationUnitAsync method, and then inject your subclass in OrganizationAppService.
-
0
@aaron Thanks! This worked. Our code for those interested:
public class CustomOrganizationUnitManager : OrganizationUnitManager { public CustomOrganizationUnitManager(IRepository<OrganizationUnit, long> organizationUnitRepository) : base(organizationUnitRepository) { } protected override Task ValidateOrganizationUnitAsync(OrganizationUnit organizationUnit) { return Task.CompletedTask; } }
usage
public OuManager(IRepository<OrganizationUnit, long> organizationUnitRepository, IRepository<UserOrganizationUnit, long> userOrganizationUnitRepository) { _organizationUnitManager = new CustomOrganizationUnitManager(organizationUnitRepository); _organizationUnitRepository = organizationUnitRepository; _userOrganizationUnitRepository = userOrganizationUnitRepository; }
-
0
That's great :)