当前位置: 首页>>代码示例>>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;未经允许,请勿转载。