本文整理汇总了C#中Customer类的典型用法代码示例。如果您正苦于以下问题:C# Customer类的具体用法?C# Customer怎么用?C# Customer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Customer类属于命名空间,在下文中一共展示了Customer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCustomer
public void CreateCustomer(Customer customer)
{
using (TransactionScope scope = new TransactionScope())
{
try
{
Log.Info($"Criando um novo usuário com o CPF {customer.CPF}");
if (this.ExistsCustomer(customer))
throw new Exception($"CPF {customer.CPF} já cadastrado");
var userId = Guid.NewGuid();
customer.Id = userId;
customer.Password = Infra.Utils.SecurityUtils.HashSHA1(customer.Password);
this.customerRepository.Save(customer);
if (!this.Login(customer.Email, customer.Password, true, false))
throw new Exception("Usuário não cadastrado, por favor tente mais tarde");
}
catch (Exception ex)
{
Log.Error(ex.Message, ex);
this.LogOut();
throw;
}
finally
{
Log.Info($"Finalizando a criação de um novo usuário com o CPF {customer.CPF}");
scope.Complete();
}
}
}
示例2: ShowCustomerDetails
private void ShowCustomerDetails(Customer customer)
{
hidCustomerID.Value = customer.ID;
lblCustomerID.Text = customer.ID;
txtCompanyName.Text = customer.CompanyName;
txtContactName.Text = customer.ContactName;
}
示例3: Serialize
public void Serialize(SerializedData data, Customer customer)
{
foreach (var formatter in _formatters)
{
formatter.Serialize(data, customer);
}
}
示例4: InsertCustomer
public void InsertCustomer(Customer customer)
{
using (SqlConnection conn = CreateConnection())
{
try
{
SqlCommand cmd = new SqlCommand("dbo.usp_createKund",conn);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.Add("@Personnummer",SqlDbType.VarChar, 15).Value = customer.PersonalNumber;
cmd.Parameters.Add("@Förnamn",SqlDbType.VarChar,15).Value = customer.FirstName;
cmd.Parameters.Add("@Efternamn",SqlDbType.VarChar,40).Value = customer.LastName;
cmd.Parameters.Add("@Adress",SqlDbType.VarChar,6).Value = customer.PostalCode;
cmd.Parameters.Add("@Ort",SqlDbType.VarChar,20).Value = customer.Town;
cmd.Parameters.Add("@Epost",SqlDbType.VarChar,30).Value = customer.Email;
cmd.Parameters.Add("@KundID",SqlDbType.Int,4).Direction = ParameterDirection.Output;
conn.Open();
cmd.ExecuteNonQuery();
customer.CustomerID = (int)cmd.Parameters["@KundID"].Value;
}
catch
{
throw new ApplicationException("Något gick fel när du försökte lägga till en ny kund");
}
}
}
示例5: Update
//Update
public static void Update(Customer customer, string lastName, string firstName, string telephone, string emailAddress)
{
customer.FirstName = firstName;
customer.LastName = lastName;
customer.TelephoneNumber = telephone;
customer.EmailAddress = emailAddress;
}
示例6: RegisterCustomer
public void RegisterCustomer(string name, CustomerType customerType)
{
try
{
using (var transaction = new TransactionScope())
{
Customer customer = new Customer();
customer.Name = name;
customer.Type = customerType;
customer.Agreements.Add(
new Agreement
{
Number = agreementManagementService.GenerateAgreementNumber(),
CreatedOn = DateTime.Now,
Customer = customer
});
repository.Save(customer);
repository.Commit();
transaction.Complete();
}
}
catch (Exception ex)
{
throw new RegistrationException(string.Format("Failed to register customer with name '{0}' and type {1}.", name, customerType), ex);
}
}
示例7: Create
public ActionResult Create(Customer cs, FormCollection collection)
{
IFormatProvider iFP = new System.Globalization.CultureInfo("vi-VN", true);
cs.CreateDate = DateTime.Parse(collection["CreateDate"], iFP);
var result = CustomerBusiness.Insert(cs);
return PartialView(cs);
}
示例8: Account
protected Account(Customer customer, decimal balance, decimal interestRate, uint validityInMonths = 6)
{
this.Customer = customer;
this.Balance = balance;
this.InterestRate = interestRate;
this.ValidityInMonths = validityInMonths;
}
示例9: Should_Return_The_Last_Inserted_Ids
public void Should_Return_The_Last_Inserted_Ids()
{
// Arrange
const string sql = @"
CREATE TABLE IF NOT EXISTS Customer
(
CustomerId INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
FirstName NVARCHAR(120) NOT NULL,
LastName NVARCHAR(120) NOT NULL,
DateOfBirth DATETIME NOT NULL
);";
var dbConnection = Sequelocity.CreateDbConnection( ConnectionStringsNames.SqliteInMemoryDatabaseConnectionString );
new DatabaseCommand( dbConnection )
.SetCommandText( sql )
.ExecuteNonQuery( true );
var customer1 = new Customer { FirstName = "Clark", LastName = "Kent", DateOfBirth = DateTime.Parse( "06/18/1938" ) };
var customer2 = new Customer { FirstName = "Bruce", LastName = "Wayne", DateOfBirth = DateTime.Parse( "05/27/1939" ) };
var customer3 = new Customer { FirstName = "Peter", LastName = "Parker", DateOfBirth = DateTime.Parse( "08/18/1962" ) };
var list = new List<Customer> { customer1, customer2, customer3 };
// Act
var customerIds = new DatabaseCommand( dbConnection )
.GenerateInsertsForSQLite( list )
.ExecuteToList<long>();
// Assert
Assert.That( customerIds.Count == 3 );
Assert.That( customerIds[0] == 1 );
Assert.That( customerIds[1] == 2 );
Assert.That( customerIds[2] == 3 );
}
示例10: Main
static void Main()
{
Customer examplePerson = new Customer("Example Person", CustomerType.Individual);
Customer exampleCompany = new Customer("Example Company", CustomerType.Company);
DepositAccount deposit = new DepositAccount(examplePerson, 1200, (decimal)0.02);
int period = 2;
Console.WriteLine("Interest for: {0}, account type: {1}, balance: {2}, period: {3} months, interest rate: {4}%\n{5}%",
deposit.Customer, deposit.GetType(), deposit.Balance, period, deposit.IntrestRate, deposit.CalcInterestAmount(period));
deposit.Withdraw(300);
Console.WriteLine("Interest for: {0}, account type: {1}, balance: {2}, period: {3} months, interest rate: {4}%\n{5}%",
deposit.Customer, deposit.GetType(), deposit.Balance, period, deposit.IntrestRate, deposit.CalcInterestAmount(period));
deposit.Deposit(1000);
Console.WriteLine("Test depositing money balance: {0}", deposit.Balance);
period = 3;
Loan loan = new Loan(examplePerson, 1200, (decimal)0.02);
Console.WriteLine("Interest for: {0}, account type: {1}, balance: {2}, period: {3} months, interest rate: {4}%\n{5}%",
loan.Customer, loan.GetType(), loan.Balance, period, loan.IntrestRate, loan.CalcInterestAmount(period));
period = 4;
Console.WriteLine("Interest for: {0}, account type: {1}, balance: {2}, period: {3} months, interest rate: {4}%\n{5}%",
loan.Customer, loan.GetType(), loan.Balance, period, loan.IntrestRate, loan.CalcInterestAmount(period));
loan.Deposit(1200);
Console.WriteLine("After repaying the loan the balance is: {0}", loan.Balance);
//invalid period test
//Console.WriteLine(loan.CalcInterestAmount(-3));
}
示例11: can_commit_multiple_db_operations
public void can_commit_multiple_db_operations()
{
var customer = new Customer { FirstName = "John", LastName = "Doe" };
var salesPerson = new SalesPerson { FirstName = "Jane", LastName = "Doe", SalesQuota = 2000 };
using (var scope = new UnitOfWorkScope())
{
new EFRepository<Customer>().Add(customer);
new EFRepository<SalesPerson>().Add(salesPerson);
scope.Commit();
}
using (var ordersTestData = new EFTestData(OrdersContextProvider()))
using (var hrTestData = new EFTestData(HRContextProvider()))
{
Customer savedCustomer = null;
SalesPerson savedSalesPerson = null;
ordersTestData.Batch(action => savedCustomer = action.GetCustomerById(customer.CustomerID));
hrTestData.Batch(action => savedSalesPerson = action.GetSalesPersonById(salesPerson.Id));
Assert.That(savedCustomer, Is.Not.Null);
Assert.That(savedSalesPerson, Is.Not.Null);
Assert.That(savedCustomer.CustomerID, Is.EqualTo(customer.CustomerID));
Assert.That(savedSalesPerson.Id, Is.EqualTo(salesPerson.Id));
}
}
示例12: Charge
public static bool Charge(Customer customer, CreditCard creditCard, decimal amount)
{
var chargeDetails = new StripeChargeCreateOptions();
chargeDetails.Amount = (int)amount * 100;
chargeDetails.Currency = "usd";
chargeDetails.Source = new StripeSourceOptions
{
Object = "card",
Number = creditCard.CcNumber,
ExpirationMonth = creditCard.ExpireDate.Month.ToString(),
ExpirationYear = creditCard.ExpireDate.Year.ToString(),
Cvc = creditCard.CVCCode
};
var chargeService = new StripeChargeService(stripeApiKey);
var response = chargeService.Create(chargeDetails);
if(response.Paid == false)
{
throw new Exception(response.FailureMessage);
}
return response.Paid;
}
示例13: testThreeAcounts
public void testThreeAcounts()
{
Customer oscar = new Customer("Oscar")
.openAccount(new Account(Account.SAVINGS));
oscar.openAccount(new Account(Account.CHECKING));
Assert.AreEqual(3, oscar.getNumberOfAccounts());
}
示例14: testAppWithTransfer
public void testAppWithTransfer()
{
Account checkingAccount = new Account(Account.CHECKING);
Account savingsAccount = new Account(Account.SAVINGS);
Customer henry = new Customer("Henry").openAccount(checkingAccount).openAccount(savingsAccount);
checkingAccount.deposit(100.0, false);
savingsAccount.deposit(4000.0, false);
savingsAccount.withdraw(200.0, false);
henry.transfer(savingsAccount, checkingAccount, 400);
Assert.AreEqual("Statement for Henry\n" +
"\n" +
"Checking Account\n" +
" deposit $100.00\n" +
" transfer to $400.00\n" +
"Total $500.00\n" +
"\n" +
"Savings Account\n" +
" deposit $4,000.00\n" +
" withdrawal $200.00\n" +
" transfer from $400.00\n" +
"Total $3,400.00\n" +
"\n" +
"Total In All Accounts $3,900.00", henry.getStatement());
}
示例15: AddCustomer
private Customer AddCustomer()
{
Customer customer = new Customer()
{
Address = BillingAddressControl.Address,
CellPhone = CellPhoneTextBox.Text,
City = BillingAddressControl.City,
Company = ComapnyTextBox.Text,
CountryID = BillingAddressControl.CountryID,
DateCreated = DateTime.Now,
DateUpdated = DateTime.Now,
DayPhone = DayPhoneTextBox.Text,
Email = EmailTextBox.Text,
EveningPhone = EveningPhoneTextBox.Text,
Fax = FaxTextBox.Text,
StateID = BillingAddressControl.StateID,
FirstName = FirstNameTextBox.Text,
LastName = LastNameTextBox.Text,
ProvinceID = BillingAddressControl.ProvinceID,
Zipcode = BillingAddressControl.Zipcode,
Active = true
};
return CustomerManager.AddCustomer(customer);
}