예제 #1
0
        private async Task <APEntity> _newCollection(string type, string attributedTo)
        {
            var obj = new ASObject();

            obj["type"].Add(new ASTerm("OrderedCollection"));
            obj["attributedTo"].Add(new ASTerm(attributedTo));
            obj.Replace("id", new ASTerm(await _entityData.FindUnusedID(_entityStore, obj, type, attributedTo)));
            var entity = APEntity.From(obj, true);

            entity.Type = "_" + type;
            entity      = await _entityStore.StoreEntity(entity);

            await _entityStore.CommitChanges();

            return(entity);
        }
예제 #2
0
        public async Task <IActionResult> PostEntity(string id)
        {
            string data;

            using (var reader = new StreamReader(Request.Body))
                data = await reader.ReadToEndAsync();
            var entity = await _entityStore.GetEntity(id, true);

            if (entity == null)
            {
                return(NotFound());
            }

            entity.Data = ASObject.Parse(data);
            await _entityStore.StoreEntity(entity);

            await _entityStore.CommitChanges();

            return(Ok());
        }