Exemplo n.º 1
0
        public void TestAttach()
        {
            ContactInformation contactInformation1 = new ContactInformation()
            {
                Phone = "phone1", Email = "*****@*****.**"
            };
            var customer1 = new Customer()
            {
                Name = "Customer1", ContactInformation = contactInformation1
            };

            customerRepository.Attach(customer1);

            customerRepository.UnitOfWork.Local <Customer>().Should().NotBeEmpty()
            .And.HaveCount(1)
            .And.ContainItemsAssignableTo <Customer>();
        }
Exemplo n.º 2
0
        internal void UpdateCustomerProfile(int contactId, string title, string lastName,
                                            string firstName, DateTime birthday, int height, int weight,
                                            string restrictions, int primaryDestinationId, int primaryActivityId,
                                            int secondaryDestinationId, int secondaryActivityId)
        {
            _cRep = new CustomerRepository(_uow);
            var origCust = HttpContext.Current.Session["Cust" + contactId] as Customer;

            _cRep.Attach(origCust);

            //TODO: test for origCust==null and deal with it if necessary

            //update only non-null fields from client
            if (title != origCust.Title)
            {
                origCust.Title = title;
            }
            if (lastName.Trim() != origCust.LastName)
            {
                origCust.LastName = lastName;
            }
            if (firstName != origCust.FirstName)
            {
                origCust.FirstName = firstName;
            }
            if (birthday != origCust.BirthDate)
            {
                origCust.BirthDate = birthday;
            }
            if (weight != origCust.WeightPounds)
            {
                origCust.WeightPounds = weight;
            }
            if (height != origCust.HeightInches)
            {
                origCust.HeightInches = height;
            }
            if (restrictions != origCust.DietaryRestrictions)
            {
                origCust.DietaryRestrictions = restrictions;
            }
            if (primaryDestinationId != origCust.PrimaryDestinationID)
            {
                origCust.PrimaryDestinationID = primaryDestinationId;
            }
            if (primaryActivityId != origCust.PrimaryActivityID)
            {
                origCust.PrimaryActivityID = primaryActivityId;
            }
            if (secondaryDestinationId != origCust.SecondaryDestinationID)
            {
                origCust.SecondaryDestinationID = secondaryDestinationId;
            }
            if (secondaryActivityId != origCust.SecondaryActivityID)
            {
                origCust.SecondaryActivityID = secondaryActivityId;
            }

            _uow.Save();
            RetrieveAndStoreCustomerGraph(contactId);
        }