コード例 #1
0
        public async Task IsAddedToAddressBook_AddedToAddressBook()
        {
            var testNotification = GetTestImportNotification(true);

            A.CallTo(() => draftImportNotificationRepository.Get(notificationId)).Returns(testNotification);

            handler = new AddImportAddressBookEntryHandler(context, userContext, addressBookRepository, draftImportNotificationRepository);

            var result = await handler.HandleAsync(message);

            Assert.True(result);
            A.CallTo(() => addressBookRepository.Update(addressBook)).MustHaveHappened();
        }
コード例 #2
0
        public async Task <bool> HandleAsync(AddAddressBookEntry message)
        {
            var addressBook = await addressBookRepository.GetAddressBookForUser(userContext.UserId, message.Type);

            var address = await GetAddress(message);

            var business = GetBusiness(message);
            var contact  = ValueObjectInitializer.CreateContact(message.Contact);

            addressBook.Add(new AddressBookRecord(address, business, contact));

            await addressBookRepository.Update(addressBook);

            return(true);
        }
コード例 #3
0
        public async Task <bool> HandleAsync(AddNewAddressBookEntry message)
        {
            var addressBook = await addressBookRepository.GetAddressBookForUser(userContext.UserId, message.Type);

            var country = await context.Countries.SingleAsync(c => c.Id == message.Address.CountryId);

            var address  = ValueObjectInitializer.CreateAddress(message.Address, country.Name);
            var business = ValueObjectInitializer.CreateBusiness(message.Business);
            var contact  = ValueObjectInitializer.CreateContact(message.Contact);

            addressBook.Add(new AddressBookRecord(address, business, contact));

            await addressBookRepository.Update(addressBook);

            return(true);
        }
コード例 #4
0
        private async Task AddToAddressBookForType(AddressRecordType type, ImportNotification draft)
        {
            AddressBook addressBook = await addressBookRepository.GetAddressBookForUser(userContext.UserId, type);

            switch (type)
            {
            case AddressRecordType.Facility:
                foreach (var facility in draft.Facilities.Facilities.Where(p => p.IsAddedToAddressBook))
                {
                    var facilityAddress = await FacilityAddressBookRecord(facility);

                    addressBook.Add(facilityAddress);
                }
                if (draft.Importer.IsAddedToAddressBook)
                {
                    var importerAddress = await ImporterAddressBookRecord(draft.Importer);

                    addressBook.Add(importerAddress);
                }
                break;

            case AddressRecordType.Producer:
                if (draft.Exporter.IsAddedToAddressBook)
                {
                    var exporter = await ExporterAddressBookRecord(draft.Exporter);

                    addressBook.Add(exporter);
                }

                if (draft.Producer.IsAddedToAddressBook)
                {
                    var producer = await ProducerAddressBookRecord(draft.Producer);

                    addressBook.Add(producer);
                }

                break;

            case AddressRecordType.Carrier:
            default:
                break;
            }
            await addressBookRepository.Update(addressBook);
        }
コード例 #5
0
 void IAddressBookService.Update(AddressBook addressBook)
 {
     _repository.Update(addressBook);
 }