Пример #1
0
        public async Task <Result> UpdateImageAsync(ImageEntity imageEntity, CancellationToken cancellationToken = default(CancellationToken))
        {
            var result = await _imageCollection.ReplaceOneAsync(t => t.ImageId == imageEntity.ImageId, imageEntity, new UpdateOptions { IsUpsert = false }, cancellationToken);

            if (result.MatchedCount == 0)
            {
                return(Result.Failed(new Error("Image not found", "Image not found")));
            }
            return(Result.Success);
        }
Пример #2
0
        public async Task <Result> CreateImageAsync(ImageEntity imageEntity, CancellationToken cancellationToken = default(CancellationToken))
        {
            await _imageCollection.InsertOneAsync(imageEntity, null, cancellationToken);

            return(Result.Success);
        }