public void TestAttributes_HoldLookedUpValuesInMemory()
        {
            using (var _dbContext = new VehicleIncidentContext(CreateNewContextOptions()))
            {
                VINAttributes    attributes;
                VINDecodeService decodeService = new VINDecodeService();
                string           vinToLookup   = "1FTNW21P04EB82562";

                attributes = decodeService.GetAttributes(vinToLookup).Result;
                _dbContext.VINAttributes.Add(attributes);
                _dbContext.SaveChanges();

                _dbContext.ContainsAttributes(vinToLookup).Should().BeTrue();
            }
        }
Beispiel #2
0
        private void SetAttributes(VehicleIncident newVehicleIncident)
        {
            VINAttributes attributes;

            if (_dbContext.ContainsAttributes(newVehicleIncident.VIN))
            {
                attributes = _dbContext.VINAttributes.FirstOrDefault(x => x.VIN == newVehicleIncident.VIN);
            }
            else
            {
                attributes = _vinDecodeService.GetAttributes(newVehicleIncident.VIN).Result;
                _dbContext.VINAttributes.Add(attributes);
                _dbContext.SaveChanges();
            }

            newVehicleIncident.Make  = attributes.Make;
            newVehicleIncident.Model = attributes.Model;
            newVehicleIncident.Year  = attributes.Year;
        }