public override async Task <OrganizationUnitDto> UpdateAsync(Guid id, CreateUpdateOrganizationUnitDto input) { if (input.ParentId != null) { var parent = await _organizationUnitRepository.FindAsync(input.ParentId.Value); if (parent == null) { throw new BusinessException($"Parent OrganizationUnit with Id:{input.ParentId} not found!"); } } input.TenantId = _currentTenant.Id == null ? input.TenantId : _currentTenant.Id; return(await base.UpdateAsync(id, input)); }
public override async Task <OrganizationUnitDto> CreateAsync(CreateUpdateOrganizationUnitDto input) { var _guid = _guidGenerator.Create(); if (input.ParentId != null) { var parent = await _organizationUnitRepository.FindAsync(input.ParentId.Value); if (parent == null) { throw new BusinessException($"Parent OrganizationUnit with Id:{input.ParentId} not found!"); } } await _organizationUnitManager.CreateAsync(new OrganizationUnit(_guid, input.DisplayName, input.ParentId, _currentTenant.Id == null?input.TenantId: _currentTenant.Id)); var root1 = await _organizationUnitRepository.GetAsync(input.DisplayName); return(ObjectMapper.Map <OrganizationUnit, OrganizationUnitDto>(root1)); // return base.CreateAsync(input); }