diff --git a/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/DatabasePersistenceServiceTests.cs b/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/DatabasePersistenceServiceTests.cs index 98a2e62..3ea8a01 100644 --- a/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/DatabasePersistenceServiceTests.cs +++ b/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/DatabasePersistenceServiceTests.cs @@ -43,17 +43,17 @@ public void GetAll_ShouldCallReadAll( } [Theory, AutoMoqData] - public async Task Add_ShouldCallAppendAllAsync_WithEntity( + public async Task AddAsync_ShouldCallAppendAllAsync_WithEntity( Entity entity, [Frozen] Mock> fileServiceMock, DatabasePersistenceService persistenceService) { - await persistenceService.Add(entity); + await persistenceService.AddAsync(entity); fileServiceMock.Verify(s => s.AppendAllAsync(It.Is>(e => e.Contains(entity))), Times.Once); } [Theory, AutoMoqData] - public async Task Update_ShouldReplaceExistingEntityAndCallWriteAllAsync( + public async Task UpdateAsync_ShouldReplaceExistingEntityAndCallWriteAllAsync( List entities, Entity newEntity, [Frozen] Mock> fileServiceMock, @@ -65,7 +65,7 @@ public async Task Update_ShouldReplaceExistingEntityAndCallWriteAllAsync( .Setup(s => s.ReadAll()) .Returns(entities.ToList()); - await persistenceService.Update(newEntity); + await persistenceService.UpdateAsync(newEntity); fileServiceMock.Verify(s => s.WriteAllAsync(It.Is>(e => e.Contains(newEntity) && !e.Any(e => e.Id == entityToUpdate.Id && !e.Equals(newEntity)))), @@ -73,7 +73,7 @@ public async Task Update_ShouldReplaceExistingEntityAndCallWriteAllAsync( } [Theory, AutoMoqData] - public async Task Delete_ShouldCallWriteAllAsync_WithoutDeletedEntity( + public async Task DeleteAsync_ShouldCallWriteAllAsync_WithoutDeletedEntity( List entities, [Frozen] Mock> fileServiceMock, DatabasePersistenceService persistenceService) @@ -82,7 +82,7 @@ public async Task Delete_ShouldCallWriteAllAsync_WithoutDeletedEntity( fileServiceMock.Setup(s => s.ReadAll()).Returns(entities); - await persistenceService.Delete(entityToDelete); + await persistenceService.DeleteAsync(entityToDelete); fileServiceMock .Verify(s => s.WriteAllAsync(It.Is>(e => !e.Contains(entityToDelete))), diff --git a/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/DatabaseUniquenessLayerTests.cs b/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/DatabaseUniquenessLayerTests.cs index 8ae5223..cbc97eb 100644 --- a/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/DatabaseUniquenessLayerTests.cs +++ b/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/DatabaseUniquenessLayerTests.cs @@ -13,7 +13,7 @@ namespace AirportTicketBookingSystem.Test.Infrastructure.Service.Database; public class DatabaseUniquenessLayerTests { [Theory, AutoMoqData] - public async Task Add_EntityExists_ShouldThrow( + public async Task AddAsync_EntityExists_ShouldThrow( Entity entity, [Frozen] Mock> queryServiceMock, DatabaseUniquenessLayer uniquenessLayer) @@ -22,13 +22,13 @@ public async Task Add_EntityExists_ShouldThrow( .Setup(s => s.Exists(entity)) .Returns(true); - var action = () => uniquenessLayer.Add(entity); + var action = () => uniquenessLayer.AddAsync(entity); await action.Should().ThrowAsync(); } [Theory, AutoMoqData] - public async Task Add_EntityDoesNotExist_ShouldCallCrud( + public async Task AddAsync_EntityDoesNotExist_ShouldCallCrud( Entity entity, [Frozen] Mock> queryServiceMock, [Frozen] Mock> crudServiceMock, @@ -38,14 +38,14 @@ public async Task Add_EntityDoesNotExist_ShouldCallCrud( .Setup(s => s.Exists(entity)) .Returns(false); - var action = () => uniquenessLayer.Add(entity); + var action = () => uniquenessLayer.AddAsync(entity); await action.Should().NotThrowAsync(); - crudServiceMock.Verify(s => s.Add(entity), Times.Once); + crudServiceMock.Verify(s => s.AddAsync(entity), Times.Once); } [Theory, AutoMoqData] - public async Task UpdateOrDelete_EntityDoesNotExist_ShouldThrow( + public async Task UpdateAsyncOrDeleteAsync_EntityDoesNotExist_ShouldThrow( Entity entity, [Frozen] Mock> queryServiceMock, DatabaseUniquenessLayer uniquenessLayer) @@ -54,15 +54,15 @@ public async Task UpdateOrDelete_EntityDoesNotExist_ShouldThrow( .Setup(s => s.Exists(entity)) .Returns(false); - var updateAction = () => uniquenessLayer.Update(entity); - var deleteAction = () => uniquenessLayer.Delete(entity); + var updateAction = () => uniquenessLayer.UpdateAsync(entity); + var deleteAction = () => uniquenessLayer.DeleteAsync(entity); await updateAction.Should().ThrowAsync(); await deleteAction.Should().ThrowAsync(); } [Theory, AutoMoqData] - public async Task UpdateOrDelete_EntityExists_ShouldCallCrud( + public async Task UpdateAsyncOrDeleteAsync_EntityExists_ShouldCallCrud( Entity entity, [Frozen] Mock> queryServiceMock, [Frozen] Mock> crudServiceMock, @@ -72,12 +72,12 @@ public async Task UpdateOrDelete_EntityExists_ShouldCallCrud( .Setup(s => s.Exists(entity)) .Returns(true); - var updateAction = () => uniquenessLayer.Update(entity); - var deleteAction = () => uniquenessLayer.Delete(entity); + var updateAction = () => uniquenessLayer.UpdateAsync(entity); + var deleteAction = () => uniquenessLayer.DeleteAsync(entity); await updateAction.Should().NotThrowAsync(); - crudServiceMock.Verify(s => s.Update(entity), Times.Once); + crudServiceMock.Verify(s => s.UpdateAsync(entity), Times.Once); await deleteAction.Should().NotThrowAsync(); - crudServiceMock.Verify(s => s.Delete(entity), Times.Once); + crudServiceMock.Verify(s => s.DeleteAsync(entity), Times.Once); } } \ No newline at end of file diff --git a/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/DatabaseValidationLayerTests.cs b/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/DatabaseValidationLayerTests.cs index 28a4ab1..74dc06e 100644 --- a/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/DatabaseValidationLayerTests.cs +++ b/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/DatabaseValidationLayerTests.cs @@ -11,41 +11,41 @@ namespace AirportTicketBookingSystem.Test.Infrastructure.Service.Database; public class DatabaseValidationLayerTests { [Theory, AutoMoqData] - public async Task Add_ShouldValidateBeforeCall( + public async Task AddAsync_ShouldValidateBeforeCall( Entity entity, [Frozen] Mock validationServiceMock, [Frozen] Mock> crudServiceMock, DatabaseValidationLayer validationLayer) { - await validationLayer.Add(entity); + await validationLayer.AddAsync(entity); validationServiceMock.Verify(s => s.ValidateEntityOrThrow(entity), Times.Once); - crudServiceMock.Verify(s => s.Add(entity), Times.Once); + crudServiceMock.Verify(s => s.AddAsync(entity), Times.Once); } [Theory, AutoMoqData] - public async Task Update_ShouldValidateBeforeCall( + public async Task UpdateAsync_ShouldValidateBeforeCall( Entity entity, [Frozen] Mock validationServiceMock, [Frozen] Mock> crudServiceMock, DatabaseValidationLayer validationLayer) { - await validationLayer.Update(entity); + await validationLayer.UpdateAsync(entity); validationServiceMock.Verify(s => s.ValidateEntityOrThrow(entity), Times.Once); - crudServiceMock.Verify(s => s.Update(entity), Times.Once); + crudServiceMock.Verify(s => s.UpdateAsync(entity), Times.Once); } [Theory, AutoMoqData] - public async Task Delete_ShouldJustCall( + public async Task DeleteAsync_ShouldJustCall( Entity entity, [Frozen] Mock validationServiceMock, [Frozen] Mock> crudServiceMock, DatabaseValidationLayer validationLayer) { - await validationLayer.Delete(entity); + await validationLayer.DeleteAsync(entity); validationServiceMock.Verify(s => s.ValidateEntityOrThrow(entity), Times.Never); - crudServiceMock.Verify(s => s.Delete(entity), Times.Once); + crudServiceMock.Verify(s => s.DeleteAsync(entity), Times.Once); } } \ No newline at end of file diff --git a/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/RelationalLayers/AirportRelationalLayerTests.cs b/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/RelationalLayers/AirportRelationalLayerTests.cs index 05f2059..4125212 100644 --- a/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/RelationalLayers/AirportRelationalLayerTests.cs +++ b/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/RelationalLayers/AirportRelationalLayerTests.cs @@ -13,19 +13,19 @@ namespace AirportTicketBookingSystem.Test.Infrastructure.Service.Database.Relati public class AirportRelationalLayerTests { [Theory, AutoMoqData] - public async Task AddOrUpdate_ShouldNeverThrow( + public async Task AddAsyncOrUpdateAsync_ShouldNeverThrow( Airport airport, AirportRelationalLayer relationalLayer) { - var addAction = () => relationalLayer.Add(airport); - var updateAction = () => relationalLayer.Update(airport); + var addAction = () => relationalLayer.AddAsync(airport); + var updateAction = () => relationalLayer.UpdateAsync(airport); await addAction.Should().NotThrowAsync(); await updateAction.Should().NotThrowAsync(); } [Theory, AutoMoqData] - public async Task Delete_ShouldThrowIfRelatedFlightExist( + public async Task DeleteAsync_ShouldThrowIfRelatedFlightExist( [Frozen] string fixedAirportId, Flight flight, Airport airport, @@ -36,7 +36,7 @@ public async Task Delete_ShouldThrowIfRelatedFlightExist( .Setup(s => s.GetAll()) .Returns([flight]); - var action = () => relationalLayer.Delete(airport); + var action = () => relationalLayer.DeleteAsync(airport); await action.Should().ThrowAsync(); } diff --git a/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/RelationalLayers/BookingRelationalLayerTests.cs b/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/RelationalLayers/BookingRelationalLayerTests.cs index 9e0c9c6..590e17b 100644 --- a/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/RelationalLayers/BookingRelationalLayerTests.cs +++ b/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/RelationalLayers/BookingRelationalLayerTests.cs @@ -13,7 +13,7 @@ namespace AirportTicketBookingSystem.Test.Infrastructure.Service.Database.Relati public class BookingRelationalLayerTests { [Theory, AutoMoqData] - public async Task AddOrUpdate_ShouldThrowIfFlightDoesNotExist( + public async Task AddAsyncOrUpdateAsync_ShouldThrowIfFlightDoesNotExist( Booking booking, [Frozen] Mock> flightQueryServiceMock, BookingRelationalLayer relationalLayer) @@ -22,15 +22,15 @@ public async Task AddOrUpdate_ShouldThrowIfFlightDoesNotExist( .Setup(s => s.GetAll()) .Returns([]); - var addAction = () => relationalLayer.Add(booking); - var updateAction = () => relationalLayer.Update(booking); + var addAction = () => relationalLayer.AddAsync(booking); + var updateAction = () => relationalLayer.UpdateAsync(booking); await addAction.Should().ThrowAsync(); await updateAction.Should().ThrowAsync(); } [Theory, AutoMoqData] - public async Task AddOrUpdate_ShouldThrowIfPassengerDoesNotExist( + public async Task AddAsyncOrUpdateAsync_ShouldThrowIfPassengerDoesNotExist( Booking booking, [Frozen] Mock> passengerQueryServiceMock, BookingRelationalLayer relationalLayer) @@ -39,8 +39,8 @@ public async Task AddOrUpdate_ShouldThrowIfPassengerDoesNotExist( .Setup(s => s.GetAll()) .Returns([]); - var addAction = () => relationalLayer.Add(booking); - var updateAction = () => relationalLayer.Update(booking); + var addAction = () => relationalLayer.AddAsync(booking); + var updateAction = () => relationalLayer.UpdateAsync(booking); await addAction.Should().ThrowAsync(); await updateAction.Should().ThrowAsync(); diff --git a/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/RelationalLayers/FlightRelationalLayerTests.cs b/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/RelationalLayers/FlightRelationalLayerTests.cs index 6fd533e..e8206a5 100644 --- a/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/RelationalLayers/FlightRelationalLayerTests.cs +++ b/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/RelationalLayers/FlightRelationalLayerTests.cs @@ -13,7 +13,7 @@ namespace AirportTicketBookingSystem.Test.Infrastructure.Service.Database.Relati public class FlightRelationalLayerTests { [Theory, AutoMoqData] - public async Task AddOrUpdate_ShouldThrowIfAirportDoesNotExist( + public async Task AddAsyncOrUpdateAsync_ShouldThrowIfAirportDoesNotExist( Flight flight, [Frozen] Mock> airportQueryServiceMock, FlightRelationalLayer relationalLayer) @@ -22,15 +22,15 @@ public async Task AddOrUpdate_ShouldThrowIfAirportDoesNotExist( .Setup(s => s.GetAll()) .Returns([]); - var addAction = () => relationalLayer.Add(flight); - var updateAction = () => relationalLayer.Update(flight); + var addAction = () => relationalLayer.AddAsync(flight); + var updateAction = () => relationalLayer.UpdateAsync(flight); await addAction.Should().ThrowAsync(); await updateAction.Should().ThrowAsync(); } [Theory, AutoMoqData] - public async Task Delete_ShouldThrowIfRelatedBookingExist( + public async Task DeleteAsync_ShouldThrowIfRelatedBookingExist( [Frozen] int fixedBookingId, Booking booking, Flight flight, @@ -41,7 +41,7 @@ public async Task Delete_ShouldThrowIfRelatedBookingExist( .Setup(s => s.GetAll()) .Returns([booking]); - var action = () => relationalLayer.Delete(flight); + var action = () => relationalLayer.DeleteAsync(flight); await action.Should().ThrowAsync(); } diff --git a/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/RelationalLayers/PassengerRelationalLayerTests.cs b/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/RelationalLayers/PassengerRelationalLayerTests.cs index 33e4843..9a45349 100644 --- a/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/RelationalLayers/PassengerRelationalLayerTests.cs +++ b/AirportTicketBookingSystem.Test/Infrastructure/Service/Database/RelationalLayers/PassengerRelationalLayerTests.cs @@ -13,19 +13,19 @@ namespace AirportTicketBookingSystem.Test.Infrastructure.Service.Database.Relati public class PassengerRelationalLayerTests { [Theory, AutoMoqData] - public async Task AddOrUpdate_ShouldNeverThrow( + public async Task AddAsyncOrUpdateAsync_ShouldNeverThrow( Passenger passenger, PassengerRelationalLayer relationalLayer) { - var addAction = () => relationalLayer.Add(passenger); - var updateAction = () => relationalLayer.Update(passenger); + var addAction = () => relationalLayer.AddAsync(passenger); + var updateAction = () => relationalLayer.UpdateAsync(passenger); await addAction.Should().NotThrowAsync(); await updateAction.Should().NotThrowAsync(); } [Theory, AutoMoqData] - public async Task Delete_ShouldThrowIfRelatedBookingExist( + public async Task DeleteAsync_ShouldThrowIfRelatedBookingExist( [Frozen] int fixedBookingId, Booking booking, Passenger passenger, @@ -36,7 +36,7 @@ public async Task Delete_ShouldThrowIfRelatedBookingExist( .Setup(s => s.GetAll()) .Returns([booking]); - var action = () => relationalLayer.Delete(passenger); + var action = () => relationalLayer.DeleteAsync(passenger); await action.Should().ThrowAsync(); } diff --git a/AirportTicketBookingSystem/src/Infrastructure/Interfaces/ICrudDatabaseService.cs b/AirportTicketBookingSystem/src/Infrastructure/Interfaces/ICrudDatabaseService.cs index f7f1824..2171f8c 100644 --- a/AirportTicketBookingSystem/src/Infrastructure/Interfaces/ICrudDatabaseService.cs +++ b/AirportTicketBookingSystem/src/Infrastructure/Interfaces/ICrudDatabaseService.cs @@ -18,7 +18,7 @@ public interface ICrudDatabaseService /// Thrown when an entity already exists in the database. /// Or when entity is invalid (against its own attributes). /// Thrown when a violation of relational constraints occurs. - Task Add(TEntity entity); + Task AddAsync(TEntity entity); /// /// Updates an existing entity with a new entity in the database. @@ -29,7 +29,7 @@ public interface ICrudDatabaseService /// Or when entity is invalid (against its own attributes). /// Thrown when a violation of relational constraints occurs. /// A task representing the update operation. - Task Update(TEntity newEntity); + Task UpdateAsync(TEntity newEntity); /// /// Deletes an entity of type from the database. @@ -38,5 +38,5 @@ public interface ICrudDatabaseService /// Thrown when the entity does not exist. /// Thrown when a violation of relational constraints occurs. /// A task representing the delete operation. - Task Delete(TEntity entity); + Task DeleteAsync(TEntity entity); } \ No newline at end of file diff --git a/AirportTicketBookingSystem/src/Infrastructure/Repository/AirportRepository.cs b/AirportTicketBookingSystem/src/Infrastructure/Repository/AirportRepository.cs index 65ba8a0..90ea5aa 100644 --- a/AirportTicketBookingSystem/src/Infrastructure/Repository/AirportRepository.cs +++ b/AirportTicketBookingSystem/src/Infrastructure/Repository/AirportRepository.cs @@ -17,7 +17,7 @@ public AirportRepository( _crudDatabaseService = crudDatabaseService; } - public void Add(Airport airport) => _crudDatabaseService.Add(airport); + public void Add(Airport airport) => _crudDatabaseService.AddAsync(airport); public IEnumerable GetAll() => _queryDatabaseService.GetAll(); diff --git a/AirportTicketBookingSystem/src/Infrastructure/Repository/BookingRepository.cs b/AirportTicketBookingSystem/src/Infrastructure/Repository/BookingRepository.cs index a27f541..32ba87f 100644 --- a/AirportTicketBookingSystem/src/Infrastructure/Repository/BookingRepository.cs +++ b/AirportTicketBookingSystem/src/Infrastructure/Repository/BookingRepository.cs @@ -17,11 +17,11 @@ public BookingRepository( _crudDatabaseService = crudDatabaseService; } - public void Add(Booking booking) => _crudDatabaseService.Add(booking); + public void Add(Booking booking) => _crudDatabaseService.AddAsync(booking); - public void Update(Booking booking) => _crudDatabaseService.Update(booking); + public void Update(Booking booking) => _crudDatabaseService.UpdateAsync(booking); - public void Delete(Booking booking) => _crudDatabaseService.Delete(booking); + public void Delete(Booking booking) => _crudDatabaseService.DeleteAsync(booking); public IEnumerable GetAll() => _queryDatabaseService.GetAll(); diff --git a/AirportTicketBookingSystem/src/Infrastructure/Repository/FlightRepository.cs b/AirportTicketBookingSystem/src/Infrastructure/Repository/FlightRepository.cs index 3ec4870..db6461f 100644 --- a/AirportTicketBookingSystem/src/Infrastructure/Repository/FlightRepository.cs +++ b/AirportTicketBookingSystem/src/Infrastructure/Repository/FlightRepository.cs @@ -17,7 +17,7 @@ public FlightRepository( _crudDatabaseService = crudDatabaseService; } - public void Add(Flight flight) => _crudDatabaseService.Add(flight); + public void Add(Flight flight) => _crudDatabaseService.AddAsync(flight); public IEnumerable GetAll() => _queryDatabaseService.GetAll(); diff --git a/AirportTicketBookingSystem/src/Infrastructure/Repository/PassengerRepository.cs b/AirportTicketBookingSystem/src/Infrastructure/Repository/PassengerRepository.cs index da58d5e..288e271 100644 --- a/AirportTicketBookingSystem/src/Infrastructure/Repository/PassengerRepository.cs +++ b/AirportTicketBookingSystem/src/Infrastructure/Repository/PassengerRepository.cs @@ -17,7 +17,7 @@ public PassengerRepository( _crudDatabaseService = crudDatabaseService; } - public void Add(Passenger passenger) => _crudDatabaseService.Add(passenger); + public void Add(Passenger passenger) => _crudDatabaseService.AddAsync(passenger); public Passenger? GetById(int id) => _queryDatabaseService .GetAll() diff --git a/AirportTicketBookingSystem/src/Infrastructure/Service/Database/DatabasePersistenceService.cs b/AirportTicketBookingSystem/src/Infrastructure/Service/Database/DatabasePersistenceService.cs index cefbca2..1773b50 100644 --- a/AirportTicketBookingSystem/src/Infrastructure/Service/Database/DatabasePersistenceService.cs +++ b/AirportTicketBookingSystem/src/Infrastructure/Service/Database/DatabasePersistenceService.cs @@ -18,19 +18,19 @@ public class DatabasePersistenceService : IQueryDatabaseService GetAll().Any(e => e.Equals(entity)); - public async Task Add(TEntity entity) + public async Task AddAsync(TEntity entity) { await _fileService.AppendAllAsync(Enumerable.Repeat(entity, 1)); } - public async Task Update(TEntity newEntity) + public async Task UpdateAsync(TEntity newEntity) { var cache = GetAll().ToList(); var changes = cache.Select(e => e.Equals(newEntity) ? newEntity : e); await _fileService.WriteAllAsync(changes); } - public async Task Delete(TEntity entity) + public async Task DeleteAsync(TEntity entity) { var cache = GetAll().ToList(); var changes = cache.Where(e => !e.Equals(entity)); diff --git a/AirportTicketBookingSystem/src/Infrastructure/Service/Database/DatabaseRelationalLayer.cs b/AirportTicketBookingSystem/src/Infrastructure/Service/Database/DatabaseRelationalLayer.cs index bf1b472..aa5965a 100644 --- a/AirportTicketBookingSystem/src/Infrastructure/Service/Database/DatabaseRelationalLayer.cs +++ b/AirportTicketBookingSystem/src/Infrastructure/Service/Database/DatabaseRelationalLayer.cs @@ -17,36 +17,36 @@ public abstract class DatabaseRelationalLayer : ICrudDatabaseService databaseService) => _databaseService = databaseService; - public async Task Add(TEntity entity) + public async Task AddAsync(TEntity entity) { ValidateAddOrThrow(entity); - await _databaseService.Add(entity); + await _databaseService.AddAsync(entity); } - public async Task Update(TEntity newEntity) + public async Task UpdateAsync(TEntity newEntity) { ValidateUpdateOrThrow(newEntity); - await _databaseService.Update(newEntity); + await _databaseService.UpdateAsync(newEntity); } - public async Task Delete(TEntity entity) + public async Task DeleteAsync(TEntity entity) { ValidateDeleteOrThrow(entity); - await _databaseService.Delete(entity); + await _databaseService.DeleteAsync(entity); } /// - /// Throws if operation is not allowed. + /// Throws if operation is not allowed. /// protected abstract void ValidateAddOrThrow(TEntity entity); /// - /// Throws if operation is not allowed. + /// Throws if operation is not allowed. /// protected abstract void ValidateUpdateOrThrow(TEntity newEntity); /// - /// Throws if operation is not allowed. + /// Throws if operation is not allowed. /// protected abstract void ValidateDeleteOrThrow(TEntity entity); } \ No newline at end of file diff --git a/AirportTicketBookingSystem/src/Infrastructure/Service/Database/DatabaseUniquenessLayer.cs b/AirportTicketBookingSystem/src/Infrastructure/Service/Database/DatabaseUniquenessLayer.cs index cd5057f..76ebbc0 100644 --- a/AirportTicketBookingSystem/src/Infrastructure/Service/Database/DatabaseUniquenessLayer.cs +++ b/AirportTicketBookingSystem/src/Infrastructure/Service/Database/DatabaseUniquenessLayer.cs @@ -23,27 +23,27 @@ public DatabaseUniquenessLayer( _crudService = crudService; } - public async Task Add(TEntity entity) + public async Task AddAsync(TEntity entity) { if (_queryService.Exists(entity)) throw new DatabaseOperationException($"Entity {entity} already exists in the database"); - await _crudService.Add(entity); + await _crudService.AddAsync(entity); } - public async Task Update(TEntity newEntity) + public async Task UpdateAsync(TEntity newEntity) { if (!_queryService.Exists(newEntity)) throw new DatabaseOperationException($"Entity {newEntity} was not found in the database"); - await _crudService.Update(newEntity); + await _crudService.UpdateAsync(newEntity); } - public async Task Delete(TEntity entity) + public async Task DeleteAsync(TEntity entity) { if (!_queryService.Exists(entity)) throw new DatabaseOperationException($"Entity {entity} was not found in the database"); - await _crudService.Delete(entity); + await _crudService.DeleteAsync(entity); } } \ No newline at end of file diff --git a/AirportTicketBookingSystem/src/Infrastructure/Service/Database/DatabaseValidationLayer.cs b/AirportTicketBookingSystem/src/Infrastructure/Service/Database/DatabaseValidationLayer.cs index bf692ed..56bb942 100644 --- a/AirportTicketBookingSystem/src/Infrastructure/Service/Database/DatabaseValidationLayer.cs +++ b/AirportTicketBookingSystem/src/Infrastructure/Service/Database/DatabaseValidationLayer.cs @@ -36,20 +36,20 @@ private void ValidateOrThrow(TEntity entity) } } - public async Task Add(TEntity entity) + public async Task AddAsync(TEntity entity) { ValidateOrThrow(entity); - await _databaseService.Add(entity); + await _databaseService.AddAsync(entity); } - public async Task Update(TEntity newEntity) + public async Task UpdateAsync(TEntity newEntity) { ValidateOrThrow(newEntity); - await _databaseService.Update(newEntity); + await _databaseService.UpdateAsync(newEntity); } - public async Task Delete(TEntity entity) + public async Task DeleteAsync(TEntity entity) { - await _databaseService.Delete(entity); + await _databaseService.DeleteAsync(entity); } } \ No newline at end of file