Exemplo n.º 1
0
        private static Contact GetContact(MongoDbTask mongoDbTask)
        {
            var result = default(Contact);
            var mongoDbContactsDataSource = new MongoDbContactsDataSource();

            result = mongoDbContactsDataSource.GetContact(mongoDbTask.ContactId);
            return(result);
        }
        public void SaveCustomer(Customer customer)
        {
            if (customer.Id == 0)
            {
                customer.Id = NewId();
                var mongoDbAddressesDataSource = new MongoDbAddressesDataSource();
                var addrssId = mongoDbAddressesDataSource.SaveAddress(customer.Address);
                customer.Address.Id = addrssId;
                var mongoDbContactsDataSource = new MongoDbContactsDataSource();
                var contactId = mongoDbContactsDataSource.SaveContact(customer.Contact);
                customer.Contact.Id         = addrssId;
                customer.Contact.Address    = new Address();
                customer.Contact.Address.Id = addrssId;
            }

            var mongoDbCustomer = new MongoDbCustomer(customer);

            mongoDbCustomer.LastModified = DateTime.Now;
            var customersCollection = GetCustomersCollection();

            customersCollection.Save(mongoDbCustomer);
        }