public ProxyResponse <UpdateContactAggregateResult> UpdateContactAggregate(ContactAggregate contactAggregate, int contactId) { OperationMethod = HttpMethod.Put; var uri = base.GetRequestUri(contactId.ToString()); return(base.GetResponse <ContactAggregate, UpdateContactAggregateResult>(uri, contactAggregate)); }
public ProxyResponse <InsertContactAggregateResult> InsertContactAggregate(ContactAggregate contactAggregate) { OperationMethod = HttpMethod.Post; var uri = base.GetRequestUri(null); return(base.GetResponse <ContactAggregate, InsertContactAggregateResult>(uri, contactAggregate)); }
private ContactAggregate GetNewContactAggregate() { var contactAggregate = new ContactAggregate { FamilyName = "Last".MakeUnique(), GivenName = "First".MakeUnique(), EmailAddress = "me@test".MakeUnique() + ".com", ContactId = "1234", Fax = "0244445555", IsContractor = true, IsCustomer = true, IsPartner = true, MiddleInitials = "PK", IsSupplier = true, MobilePhone = "0412341234", HomePhone = "0245674567", PositionTitle = "Super hero", PostalAddress = new Address() { City = "Sydney", Country = "Australia", Postcode = "2000", State = "NSW", Street = "Elizabeth Street" }, PrimaryPhone = "0278977897", Salutation = "Mr.", Company = new Company() { Name = "MyCo".MakeUnique(), Abn = "12345678", CompanyEmail = "*****@*****.**", LongDescription = "My company", TradingName = "MyTrading", }, ContactManager = new ContactManager() { FamilyName = "Pan".MakeUnique(), GivenName = "Blossom".MakeUnique(), MiddleInitials = "F", Salutation = "Ms.", PositionTitle = "High flyer", } }; return(contactAggregate); }
public void Add(IAccountContactSummary contact) { if (!_isTrackingChanges) throw new InvalidOperationException("Add must be called while tracking changes"); //Look for matches var existing = _contacts.SingleOrDefault(c => c.OwnsContact(contact)); if (existing != null) { if (contact.IsDeleted) { existing.Remove(contact); } else { existing.Update(contact); } return; } //The provider could send us a Delete for a contact we don't know about. if(contact.IsDeleted) return; //This pattern produces different results with different order of input. If A & B can be linked on email, and B & C can be linked on phone, then Adding A, then B, thne C will result in one Aggregate contact (ABC). However adding A then C then B will result in two aggregates (AB & C) //var match = _contacts.Select(c => c.Match(contact)) // .OrderBy(match => match.Weight) // .FirstOrDefault(); //TODO: Update to allow for the A,C,B scenario above. var match = _contacts.FirstOrDefault(c => c.IsMatch(contact)); if (match != null) { match.Add(contact); return; } var newContact = new ContactAggregate(contact); _contacts.Add(newContact); }
private static void AssertUpdatedContact(ContactAggregate contactAggregate, ProxyResponse <Contact> updatedContact) { Assert.AreEqual(contactAggregate.EmailAddress, updatedContact.DataObject.EmailAddress); Assert.AreEqual(contactAggregate.ContactId, updatedContact.DataObject.ContactId); Assert.AreEqual(contactAggregate.FamilyName, updatedContact.DataObject.FamilyName); Assert.AreEqual(contactAggregate.Fax, updatedContact.DataObject.Fax); Assert.AreEqual(contactAggregate.GivenName, updatedContact.DataObject.GivenName); Assert.AreEqual(contactAggregate.IsPartner, updatedContact.DataObject.IsPartner); Assert.AreEqual(contactAggregate.IsContractor, updatedContact.DataObject.IsContractor); Assert.AreEqual(contactAggregate.IsCustomer, updatedContact.DataObject.IsCustomer); Assert.AreEqual(contactAggregate.IsPartner, updatedContact.DataObject.IsPartner); Assert.AreEqual(contactAggregate.IsSupplier, updatedContact.DataObject.IsSupplier); Assert.AreEqual(contactAggregate.MiddleInitials, updatedContact.DataObject.MiddleInitials); Assert.AreEqual(contactAggregate.MobilePhone, updatedContact.DataObject.MobilePhone); Assert.AreEqual(contactAggregate.HomePhone, updatedContact.DataObject.HomePhone); Assert.AreEqual(contactAggregate.PositionTitle, updatedContact.DataObject.PositionTitle); Assert.AreEqual(contactAggregate.PostalAddress.City, updatedContact.DataObject.PostalAddress.City); Assert.AreEqual(contactAggregate.PostalAddress.Country, updatedContact.DataObject.PostalAddress.Country); Assert.AreEqual(contactAggregate.PostalAddress.Postcode, updatedContact.DataObject.PostalAddress.Postcode); Assert.AreEqual(contactAggregate.PostalAddress.State, updatedContact.DataObject.PostalAddress.State); Assert.AreEqual(contactAggregate.PostalAddress.Street, updatedContact.DataObject.PostalAddress.Street); Assert.AreEqual(contactAggregate.PrimaryPhone, updatedContact.DataObject.PrimaryPhone); Assert.AreEqual(contactAggregate.Salutation, updatedContact.DataObject.Salutation); }