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(RegisterUser command)
        {
            var user = new Domain.Models.User(command.Username, command.Password);

            _archDbContext.Users.Add(user);
            _archDbContext.SaveChanges();
        }
        public void Handle(AddItemCart command)
        {
            var orderItem = _context.OrderItems.FirstOrDefault(x => x.Id == command.OrderItemId);

            orderItem.Qtd += command.Value;
            _context.OrderItems.Add(orderItem);
            _context.SaveChanges();
        }
        protected void Commit(Event evet)
        {
            if (_notifications.HasNotifications())
            {
                return;
            }
            if (_architectureContext.SaveChanges() > 0)
            {
                evet.Who = _authService.UserLoggedIn;
                var anterior = _eventRepository.GetLastEvent(evet.AggregateId);
                var objJson  = anterior != null
                    ? ReadToObject(((StoredEvent)anterior).Data, ((StoredEvent)anterior).Assembly)
                    : null;

                _eventRepository.Save(evet, objJson);
            }
            else
            {
                AddNotification(new DomainNotification("Commit", "We had a problem during saving your data."));
            }
        }
        public void Handle(CreateOrderItem command)
        {
            var product = _architectureContext.Products.Find(command.ProductId);

            var orderItem = _architectureContext.OrderItems.Include(x => x.Product)
                            .FirstOrDefault(x => x.Product.Id == command.ProductId);

            if (orderItem == null)
            {
                _architectureContext.OrderItems.Add(new OrderItem(product));
            }
            else
            {
                orderItem.Qtd++;
                //_architectureContext.OrderItems.Update(orderItem);
            }

            _architectureContext.SaveChanges();
        }
Пример #6
0
 public void Handle(CreateProduct command)
 {
     _context.Add(new Domain.Models.Product(command.Name, command.Description, command.Price));
     _context.SaveChanges();
 }