Пример #1
0
        private async Task <AnchorSet> CreateOrUpdateAnchor(string anchorSetId, string anchorId, string mode, string deviceId = null)
        {
            AnchorSet anchorSet = await _anchorSetDatabaseHandler.FindOne(a => a.Id == anchorSetId);

            if (anchorSet == null)
            {
                throw new NoAnchorSetException(anchorSetId);
            }
            if (anchorSet.Anchors == null)
            {
                anchorSet.Anchors = new List <Anchor>();
            }

            Anchor existingAnchor = anchorSet.Anchors.FirstOrDefault(a => a.Id == anchorId);

            if (existingAnchor != null)
            {
                anchorSet.Anchors.Remove(existingAnchor);
            }

            if (mode == VisualizerModes.Virtual)
            {
                Anchor existingVirtualAnchor = anchorSet.Anchors.FirstOrDefault();
                anchorSet.Anchors.Remove(existingVirtualAnchor);
            }

            Anchor anchor = new Anchor()
            {
                Id = anchorId, Mode = mode, DeviceId = deviceId
            };

            anchorSet.Anchors.Add(anchor);
            await _anchorSetDatabaseHandler.ReplaceOneAsync(a => a.Id == anchorSetId, anchorSet);

            return(anchorSet);
        }
Пример #2
0
        public async Task <SharedState> GetSharedState([FromRoute] string anchorSetId)
        {
            SharedState sharedState = await _database.FindOne(a => a.Id == anchorSetId);

            return(sharedState);
        }