public async Task DeleteCustomerVehicle_Should_NotFindVehicleAfterDelete()
        {
            // Arrange
            var v1 = new CustomerVehicle {
                Registration = "EF02VCC"
            };
            await repo.Create(v1, Guid.NewGuid(), Guid.NewGuid());

            var sut = new CustomerVehicleService(repo, new MockVehicleDataService());
            // Act
            await sut.DeleteCustomerVehicle(v1.Id, v1.CustomerId, v1.ClientId);

            var result = (await repo.FindAllByCustomer(v1.CustomerId, v1.ClientId)).FirstOrDefault(x => x.Registration == "EF02VCC");

            // Assert
            Assert.Null(result);
        }
Beispiel #2
0
        public async Task <CustomerVehicle> AddVehicleToCustomer(string registration, Guid customerId, Guid clientId)
        {
            var vehicles = await repo.FindAllByCustomer(customerId, clientId);

            var existing = vehicles.FirstOrDefault(x => x.Registration == registration);

            if (existing != null)
            {
                throw new Exception("Vehicle with this registration already exists");
            }

            var lookup = await vehicleData.GetVehicleData(registration);

            var vehicle = MapLookupToCustomerVehicle(lookup);
            var result  = await repo.Create(vehicle, customerId, clientId);

            return(result);
        }