Example #1
0
 public async void DeleteAsync_GivenInvalidLocationId_ReturnsFailed()
 {
     using (var repository = new LocationRepository(context))
     {
         Assert.False(await repository.DeleteAsync(-321));
     }
 }
Example #2
0
        public async void CreateAsync_GivenValidLocationDeletesIt_ReturnsSuccess()
        {
            var loc = new LocationCreateDTO
            {
                City    = "Copenhagen",
                Country = "Denmark"
            };

            using (var repository = new LocationRepository(context))
            {
                var id = await repository.CreateAsync(loc);

                Assert.Equal((await context.Locations.FirstAsync()).Id, id);
                Assert.True(await repository.DeleteAsync(id));
            }
        }
        public async Task <bool> DeleteLocation(int locationId)
        {
            // get the location
            Location location = await locationRepository.ReadAsync(locationId);

            // if location was not found
            if (location == null)
            {
                return(false);
            }

            // delete image from blob storage
            azureService.deleteImageFromBlobStorage(location.Image);

            // delete location from database
            return(await locationRepository.DeleteAsync(locationId));
        }