當前位置: 首頁>>代碼示例>>C#>>正文


C# Account.AddContact方法代碼示例

本文整理匯總了C#中Account.AddContact方法的典型用法代碼示例。如果您正苦於以下問題:C# Account.AddContact方法的具體用法?C# Account.AddContact怎麽用?C# Account.AddContact使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Account的用法示例。


在下文中一共展示了Account.AddContact方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Account_WithContacts_VerifyMap

        public void Account_WithContacts_VerifyMap()
        {
            var dealer = session.Get<AccountType>(1);
            var phone = session.Get<ContactType>(1);
            var email = session.Get<ContactType>(5);

            var account = new Account()
            {
                Name = "Acme Enterprises",
                AccountType = dealer,
                ModifyDate = DateTime.Now,
                ModifyUser = "test"
            };

            account.AddContact(
                new Contact() {
                    ContactDetail = "[email protected]",
                    DoNotify = true,
                    FirstName = "John",
                    LastName = "Dough",
                    ContactType = email,
                });
            account.AddContact(
                new Contact() {
                    ContactDetail = "123-456-7890",
                    DoNotify = false,
                    FirstName = "Jane",
                    LastName = "Dough",
                    ContactType = phone,
                });

            session.SaveOrUpdate(account);
            session.Flush();

            var account2 = session.QueryOver<Account>().Where(a => a.Id == account.Id).SingleOrDefault();
            Assert.IsNotNull(account2);
            Assert.AreEqual(2, account2.ContactList.Count);
            Assert.IsNotNull(account2.ContactList.Where(c => c.ContactDetail == "[email protected]").FirstOrDefault());
        }
開發者ID:PolishDev,項目名稱:shop-manager,代碼行數:39,代碼來源:AccountTest.cs

示例2: SaveAccount_WithContacts

        public void SaveAccount_WithContacts()
        {
            var dealer = session.Get<AccountType>(1);
            var phone = session.Get<ContactType>(1);
            var email = session.Get<ContactType>(5);

            var account = new Account()
            {
                Name = "Acme Enterprises",
                AccountType = dealer,
                ModifyDate = DateTime.Now,
                ModifyUser = "test"
            };

            account.AddContact(
                new Contact()
                {
                    ContactDetail = "[email protected]",
                    DoNotify = true,
                    FirstName = "John",
                    LastName = "Dough",
                    ContactType = email,
                });

            repository.SaveAccount(account);

            var account2 = repository.GetAccount(account.Id);
            Assert.IsNotNull(account2);
            Assert.AreEqual(1, account2.ContactList.Count);
            Assert.IsNotNull(account2.ContactList.Where(c => c.ContactDetail == "[email protected]").FirstOrDefault());
        }
開發者ID:PolishDev,項目名稱:shop-manager,代碼行數:31,代碼來源:AccountRespositoryTests.cs


注:本文中的Account.AddContact方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。