public Domain.Car.Car Add(Domain.Car.Car car)
        {
            var addedCar = _context.Cars.Add(car).Entity;

            AddDomainEntityEvents(addedCar);
            return(addedCar);
        }
        private void AddDomainEntityEvents(Domain.Car.Car car)
        {
            var carEvents = car.DomainEvents?.Select(e => (e as CarEvent));

            if (carEvents != null && carEvents.Any())
            {
                _context.CarEvents.AddRange(carEvents.Select(e => e.ToEntity()));
            }

            var tireEvents = car.Tires.Where(t => t.DomainEvents != null)
                             .SelectMany(t => t.DomainEvents?.Select(e => (e as TireEvent)));

            if (tireEvents != null && tireEvents.Any())
            {
                _context.TireEvents.AddRange(tireEvents.Select(t => t.ToEntity()));
            }
        }
 public async Task AddCar(Domain.Car.Car car)
 {
     string query = "INSERT INTO car(model, typename) VALUES(@Model, @TypeName)";
     await _dbConnection.ExecuteAsync(query, car);
 }
 public void Update(Domain.Car.Car car)
 {
     AddDomainEntityEvents(car);
     _context.Entry(car).State = EntityState.Modified;
 }
예제 #5
0
 public TireAdded(int tireId, Domain.Car.Car car, string createdBy)
     : base(() => GetCarId(car), createdBy)
 {
     TireId = tireId;
 }