Exemple #1
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);
        }
        public async Task <IActionResult> LookupVehicle(string registration)
        {
            var result = await vehicleData.GetVehicleData(registration);

            return(new OkObjectResult(result));
        }