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(); }
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); }
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); }
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); }
void IAddressBookService.Update(AddressBook addressBook) { _repository.Update(addressBook); }