Beispiel #1
0
        public async Task RemoveImage()
        {
            IImageDataAccess imageDataAccess = Setup();

            using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                var id = Guid.NewGuid();
                await imageDataAccess.SaveImageAsync(new ImageRepServiceLibrary.Model.Image()
                {
                    Id          = id,
                    Name        = "Bob",
                    Description = "A picture of Bob",
                    Picture     = "dfdsgfs",
                    DateCreated = DateTime.Now,
                    Tags        = new List <Tag>()
                    {
                        new Tag()
                        {
                            TagId    = Guid.NewGuid(),
                            Name     = "Person",
                            ImageKey = id
                        },
                        new Tag()
                        {
                            TagId    = Guid.NewGuid(),
                            Name     = "Friend",
                            ImageKey = id
                        }
                    }
                });

                int count = await imageDataAccess.DeleteImageAsync(id);

                Assert.Equal(3, count);

                id    = new Guid();
                count = await imageDataAccess.DeleteImageAsync(id);

                Assert.Equal(0, count);


                if (_commiteToDB)
                {
                    scope.Complete();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Returns true iff (An image exists with this guid AND the image (with associated tags) was removed)
        /// </summary>
        public async Task <bool> DeleteImageAsync(Guid guid)
        {
            int rowsChanged = await _imageDataAccess.DeleteImageAsync(guid);

            return(rowsChanged > 0);
        }