本文整理汇总了C#中Customer.SetAssignedIdTo方法的典型用法代码示例。如果您正苦于以下问题:C# Customer.SetAssignedIdTo方法的具体用法?C# Customer.SetAssignedIdTo怎么用?C# Customer.SetAssignedIdTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer.SetAssignedIdTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanCompareCustomers
public void CanCompareCustomers()
{
Customer customerA = new Customer("Acme");
Customer customerB = new Customer("Anvil");
Assert.AreNotEqual(customerA, null);
Assert.AreNotEqual(customerA, customerB);
customerA.SetAssignedIdTo("AAAAA");
customerB.SetAssignedIdTo("AAAAA");
// Even though the "business value signatures" are different, the persistent IDs
// were the same. Call me crazy, but I put that much trust into IDs.
Assert.AreEqual(customerA, customerB);
Customer customerC = new Customer("Acme");
// Since customerA has an ID but customerC doesn't, their signatures will be compared
Assert.AreEqual(customerA, customerC);
customerC.ContactName = "Coyote";
// Signatures are now different
Assert.AreNotEqual(customerA, customerC);
// customerA.Equals(customerB) because they have the same ID.
// customerA.Equals(customerC) because they have the same signature.
// ! customerB.Equals(customerC) because we can't compare their IDs,
// since customerC is transient, and their signatures are different.
Assert.AreNotEqual(customerB, customerC);
}
示例2: Create
public Customer Create(string companyName, string assignedId)
{
var customerToCreate = new Customer(companyName);
customerToCreate.SetAssignedIdTo(assignedId);
this.customerRepository.DbContext.BeginTransaction();
this.customerRepository.SaveOrUpdate(customerToCreate);
this.customerRepository.DbContext.CommitTransaction();
return customerToCreate;
}
示例3: btnAdd_OnClick
protected void btnAdd_OnClick(object sender, EventArgs e) {
if (txtCustomerID.Text.Trim().Length == 5) {
Customer newCustomer = new Customer(txtCompanyName.Text);
newCustomer.SetAssignedIdTo(txtCustomerID.Text);
newCustomer.ContactName = txtContactName.Text;
IDaoFactory daoFactory = new NHibernateDaoFactory();
ICustomerDao customerDao = daoFactory.GetCustomerDao();
if (!IsDuplicateOfExisting(newCustomer, customerDao)) {
customerDao.Save(newCustomer);
Response.Redirect("ListCustomers.aspx?action=added");
}
else {
lblMessage.Text =
"<span style=\"color:red\">The ID you provided is already in use.</span><br />Please change the ID and try again.";
}
}
else {
lblMessage.Text =
"<span style=\"color:red\">The ID you provide must be exactly 5 characters long.</span><br />Please change the ID and try again.";
}
}
示例4: CreatePersistedCustomer
private Customer CreatePersistedCustomer(string customerId, string contactName, string companyName, string country) {
Customer customer = new Customer(companyName) {
ContactName = contactName,
Country = country
};
customer.SetAssignedIdTo(customerId);
// We have to explicitly call Save() since it has an assigned ID
customerRepository.Save(customer);
FlushSessionAndEvict(customer);
return customer;
}