public async Task <TQueryModel> CreateAsync(TQueryModel model)
        {
            var existing = await FindAsync(model.Id);

            if (existing != null)
            {
                throw new StorageException();
            }

            storage.Add(model);

            model.Timestamp = DateTimeOffset.UtcNow;
            model.ETag      = Unified.NewCode();

            return(model);
        }
示例#2
0
        /// <inheritdoc />
        public async Task <TQueryModel> CreateAsync(TQueryModel model)
        {
            var existingModel = await FindAsync(model.Id, model.Version);

            if (existingModel != null)
            {
                throw new StorageException();
            }

            storage.Add(model);

            model.Timestamp = DateTimeOffset.UtcNow;

            return(model);
        }