Ejemplo n.º 1
0
        private static Address GetAddress(MongoDbContact mongoDbContact)
        {
            var result = default(Address);
            var mongoDbAddressesDataSource = new MongoDbAddressesDataSource();

            result = mongoDbAddressesDataSource.GetAddress(mongoDbContact.AddressId);
            return(result);
        }
Ejemplo n.º 2
0
        private static Address GetAddress(int?addressId)
        {
            var result = default(Address);

            if (addressId.HasValue)
            {
                var mongoDbAddressesDataSource = new MongoDbAddressesDataSource();

                result = mongoDbAddressesDataSource.GetAddress(addressId.Value);
            }
            return(result);
        }
Ejemplo n.º 3
0
        public int SaveContact(Contact contact)
        {
            if (contact.Id == 0)
            {
                contact.Id = NewId();
                var mongoDbAddressesDataSource = new MongoDbAddressesDataSource();
                var addrssId = mongoDbAddressesDataSource.SaveAddress(contact.Address);
                contact.Address.Id = addrssId;
            }

            var MongoDbUser = new MongoDbContact(contact);

            MongoDbUser.LastModified = DateTime.Now;
            var contactsCollection = GetContactsCollection();

            contactsCollection.Save(MongoDbUser);
            return(contact.Id);
        }
        public void SaveCompany(Company comapny)
        {
            if (comapny.Id == 0)
            {
                comapny.Id = NewId();

                var mongoDbAddressesDataSource = new MongoDbAddressesDataSource();
                var addrssId = mongoDbAddressesDataSource.SaveAddress(comapny.Address);
                comapny.Address.Id = addrssId;
            }

            var mongoDbCompany = new MongoDbCompany(comapny);

            mongoDbCompany.LastModified = DateTime.Now;

            var comapniesCollection = GetCompaniesCollection();

            comapniesCollection.Save(mongoDbCompany);
        }
        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);
        }