Example #1
0
        public CommandEntity Add(string containerName, CommandEntity entity)

        {
            containerName.GuardAgainstNullOrEmpty(nameof(containerName));
            entity.GuardAgainstNull(nameof(entity));

            var container = EnsureContainer(containerName);

            container.CreateItemAsync <dynamic>(entity.ToContainerEntity()).GetAwaiter().GetResult();

            return(Retrieve(containerName, entity.Id, entity.Metadata));
        }
Example #2
0
        public CommandEntity Replace(string containerName, string id, CommandEntity entity)
        {
            containerName.GuardAgainstNullOrEmpty(nameof(containerName));
            id.GuardAgainstNull(nameof(id));
            entity.GuardAgainstNull(nameof(entity));

            var container = EnsureContainer(containerName);

            var result = container.UpsertItemAsync <dynamic>(entity.ToContainerEntity()).GetAwaiter().GetResult();

            return(CommandEntity.FromCommandEntity(((JObject)result.Resource).FromContainerEntity(entity.Metadata),
                                                   entity));
        }