コード例 #1
0
        public void Update(ICustomerCreatedEvent command)
        {
            var customer = _context.CustomerForLists.SingleOrDefault(x => x.Id.Equals(command.Id));

            if (customer != null)
            {
                customer.Name = command.Name;
            }
            else
            {
                _context.CustomerForLists.Add(new CustomerForList {
                    Id = command.Id, Name = command.Name
                });
            }

            _context.SaveChanges();
        }
コード例 #2
0
        public void Update(ICustomerCreatedEvent command)
        {
            var customer = _context.CustomerDetails.SingleOrDefault(x => x.Id.Equals(command.Id));

            if (customer != null)
            {
                // should never happen
                customer.Name    = command.Name;
                customer.Address = command.Address;
            }
            else
            {
                _context.CustomerDetails.Add(new CustomerDetails {
                    Id = command.Id, Name = command.Name, Address = command.Address
                });
            }

            _context.SaveChanges();
        }