public AssociationUpdateInfo(RtEntityId origin, RtEntityId target, string roleId, AssociationModOptionsDto modOption) { Origin = origin; Target = target; RoleId = roleId; ModOption = modOption; }
public async Task <TEntity> GetRtEntityAsync <TEntity>(IOspSession session, RtEntityId rtEntityId) where TEntity : RtEntity, new() { ArgumentValidation.Validate(nameof(rtEntityId), rtEntityId); ArgumentValidation.ValidateString(nameof(rtEntityId.CkId), rtEntityId.CkId); ArgumentValidation.Validate(nameof(rtEntityId.RtId), rtEntityId.RtId); return(await _databaseContext.GetRtCollection <TEntity>(rtEntityId.CkId) .DocumentAsync(session, rtEntityId.RtId.ToObjectId())); }
public async Task <RtAssociation> GetRtAssociationAsync(IOspSession session, RtEntityId rtEntityIdOrigin, RtEntityId rtEntityIdTarget, string roleId) { return(await _databaseContext.RtAssociations.FindSingleOrDefaultAsync(session, x => x.OriginRtId == rtEntityIdOrigin.RtId.ToObjectId() && x.OriginCkId == rtEntityIdOrigin.CkId && x.TargetRtId == rtEntityIdTarget.RtId.ToObjectId() && x.TargetCkId == rtEntityIdTarget.CkId && x.AssociationRoleId == roleId)); }
private async Task <RtEntity> GetEntity(IOspSession session, IReadOnlyList <EntityUpdateInfo> entityUpdateInfoList, RtEntityId rtEntityId) { var rtEntity = entityUpdateInfoList.Select(x => x.RtEntity).FirstOrDefault(x => x.RtId == rtEntityId.RtId.ToObjectId()); // ReSharper disable once ConvertIfStatementToNullCoalescingExpression if (rtEntity == null) { rtEntity = await _tenantRepository.GetRtEntityAsync(session, rtEntityId); } return(rtEntity); }
public async Task <CurrentMultiplicity> GetCurrentRtAssociationMultiplicityAsync(IOspSession session, RtEntityId rtEntityId, string roleId, GraphDirections graphDirections) { long counter = 0; if (graphDirections == GraphDirections.Inbound || graphDirections == GraphDirections.Any) { var filterDefinition = Builders <RtAssociation> .Filter.And( Builders <RtAssociation> .Filter.Eq(x => x.TargetRtId, rtEntityId.RtId.ToObjectId()), Builders <RtAssociation> .Filter.Eq(x => x.TargetCkId, rtEntityId.CkId), Builders <RtAssociation> .Filter.Eq(x => x.AssociationRoleId, roleId) ); var r = await _databaseContext.RtAssociations.GetTotalCountAsync(session, filterDefinition); counter = Math.Max(r, counter); } if (graphDirections == GraphDirections.Outbound || graphDirections == GraphDirections.Any) { var filterDefinition = Builders <RtAssociation> .Filter.And( Builders <RtAssociation> .Filter.Eq(x => x.OriginRtId, rtEntityId.RtId.ToObjectId()), Builders <RtAssociation> .Filter.Eq(x => x.TargetCkId, rtEntityId.CkId), Builders <RtAssociation> .Filter.Eq(x => x.AssociationRoleId, roleId) ); var r = await _databaseContext.RtAssociations.GetTotalCountAsync(session, filterDefinition); counter = Math.Max(r, counter); } if (counter >= 2) { return(CurrentMultiplicity.Many); } if (counter == 1) { return(CurrentMultiplicity.One); } return(CurrentMultiplicity.Zero); }
public async Task <RtEntity> GetRtEntityAsync(IOspSession session, RtEntityId rtEntityId) { return(await _databaseContext.GetRtCollection <RtEntity>(rtEntityId.CkId) .DocumentAsync(session, rtEntityId.RtId.ToObjectId())); }