Ejemplo n.º 1
0
 public CustomerContextFacade()
 {
     CurrentContact = new CurrentContactFacade();
 }
Ejemplo n.º 2
0
 public CustomerContextFacade()
 {
     CurrentContact = new CurrentContactFacade();
 }
Ejemplo n.º 3
0
 public CustomerContextFacade(MapUserKey mapUserKey)
 {
     CurrentContact = new CurrentContactFacade();
     _mapUserKey    = mapUserKey;
 }
Ejemplo n.º 4
0
 public HeaderController(CurrentContactFacade currentContactFacade, IContentLoader contentLoader)
 {
     _contentLoader = contentLoader;
     _currentContactFacade = currentContactFacade;
 }
Ejemplo n.º 5
0
 private CustomerAddress GetAddress(CurrentContactFacade contact, string addressId)
 {
     return contact.ContactAddresses.FirstOrDefault(x => x.Name == addressId);
 }
Ejemplo n.º 6
0
        private CustomerAddress CreateOrUpdateCustomerAddress(CurrentContactFacade contact, AddressModel addressModel)
        {

            var customerAddress = GetAddress(contact, addressModel.AddressId);
            var isNew = customerAddress == null;
            IEnumerable<PrimaryKeyId> existingId = contact.ContactAddresses.Select(a => a.AddressId).ToList();
            if (isNew)
            {
                customerAddress = CustomerAddress.CreateInstance();
            }

            MapToAddress(addressModel, customerAddress);

            if (isNew)
            {
                contact.AddContactAddress(customerAddress);
            }
            else
            {
                contact.UpdateContactAddress(customerAddress);
            }

            contact.SaveChanges();
            if (isNew)
            {
                customerAddress.AddressId = contact.ContactAddresses
                    .Where(a => !existingId.Contains(a.AddressId))
                    .Select(a => a.AddressId)
                    .Single();
                addressModel.AddressId = customerAddress.Name;
            }
            return customerAddress;
        }
Ejemplo n.º 7
0
 private CustomerAddress GetAddress(CurrentContactFacade contact, Guid? addressId)
 {
     return addressId.HasValue ?
         contact.ContactAddresses.FirstOrDefault(x => x.AddressId == addressId.GetValueOrDefault()) :
         null;
 }
Ejemplo n.º 8
0
 public FakeCustomerContext(CurrentContactFacade currentContact)
 {
     _currentContact = currentContact;
 }