public void Handle(InsertVolumeCustomers command)
        {
            var faker = new Faker();
            var list  = new List <Domain.Models.Customer>();

            for (var i = 0; i < command.InsertsCount; i++)
            {
                var minDate = DateTime.Now.AddYears(-30);
                var maxDate = DateTime.Now.AddYears(-60);

                var customer = new Domain.Models.Customer(
                    faker.Name.FirstName(),
                    faker.Name.LastName(),
                    faker.Person.Email,
                    faker.Date.Between(minDate, maxDate));
                customer.Score = faker.Random.Int(0, 100);

                var address = new Address(faker.Address.StreetName(), faker.Address.BuildingNumber(), faker.Address.City(), faker.Address.ZipCode());
                customer.Address = address;

                list.Add(customer);
            }

            list.ForEach(_ => _architectureContext.Add(_));
            _architectureContext.SaveChanges();
        }
コード例 #2
0
 public void Handle(CreateProduct command)
 {
     _context.Add(new Domain.Models.Product(command.Name, command.Description, command.Price));
     _context.SaveChanges();
 }