本文整理汇总了C#中Account类的典型用法代码示例。如果您正苦于以下问题:C# Account类的具体用法?C# Account怎么用?C# Account使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Account类属于命名空间,在下文中一共展示了Account类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
// Main method begins execution of the app
public static void Main( string[] args )
{
// constructors
Account account1 = new Account(50.00M); //create Account object
Account account2 = new Account(-7.53M);
Console.WriteLine("Account1 balance: {0:C}\n", account1.Balance);
Console.WriteLine("Account2 balance: {0:C}\n", account2.Balance);
decimal depositAmount;
Console.WriteLine("Enter deposit ammount for account1: ");
depositAmount = Convert.ToDecimal(Console.ReadLine());
Console.WriteLine("adding {0:C} to account1 balance\n", depositAmount);
account1.Credit(depositAmount);
Console.WriteLine("account1 balance: {0:C}\n", account1.Balance);
Console.WriteLine("account2 balance: {0:C}", account2.Balance);
Console.WriteLine("Enter deposit ammount for account2: ");
depositAmount = Convert.ToDecimal(Console.ReadLine());
Console.WriteLine("adding {0:C} to account2 balance\n", depositAmount);
account2.Credit(depositAmount);
Console.WriteLine("account1 balance: {0:C}\n", account1.Balance);
Console.WriteLine("account2 balance: {0:C}", account2.Balance);
}
示例2: CreateAccount
/// <summary>
///
/// </summary>
/// <param name="account"></param>
/// <returns></returns>
public bool CreateAccount(Account account)
{
int x = 0;
var collection = MongoDb.Instance.GetCollection<Account>();
var result = collection.Insert(account);
return result.Ok;
}
示例3: Add
public string Add(Account account)
{
account.Id = Regex.Replace(account.Name, @"\W+", string.Empty).ToLower();
_accounts.Add(account);
return account.Id;
}
示例4: GetAccountByID
public Account GetAccountByID(string sAccountID)
{
Account acct = new Account();
acct.Id = new IdType { idDomain = idDomainEnum.QB, Value = sAccountID };
return getDataService().FindById<Account>(acct) as Account;
}
示例5: RenameAccountDialogViewModel
public RenameAccountDialogViewModel(ShellViewModel shell, Account account, string currentName)
: base(shell)
{
_account = account;
_rename = new DelegateCommand(RenameAction);
CurrentAccountName = currentName;
}
示例6: Init
private void Init(Account modifiedAccount)
{
account = modifiedAccount;
alert = new Alert();
alert.AccountID = account.AccountID;
alert.CreateDate = DateTime.Now;
}
示例7: MakeTransfer
public void MakeTransfer(Account creditAccount, Account debitAccount, decimal amount)
{
if (creditAccount == null)
{
throw new AccountServiceException("creditAccount null");
}
if (debitAccount == null)
{
throw new AccountServiceException("debitAccount null");
}
if (debitAccount.Balance < amount && debitAccount.AutorizeOverdraft == false)
{
throw new AccountServiceException("not enough money");
}
Operation creditOperation = new Operation() { Amount = amount, Direction = Direction.Credit};
Operation debitOperation = new Operation() { Amount = amount, Direction = Direction.Debit };
creditAccount.Operations.Add(creditOperation);
debitAccount.Operations.Add(debitOperation);
creditAccount.Balance += amount;
debitAccount.Balance -= amount;
_operationRepository.CreateOperation(creditOperation);
_operationRepository.CreateOperation(debitOperation);
_accountRepository.UpdateAccount(creditAccount);
_accountRepository.UpdateAccount(debitAccount);
}
示例8: GoldState
public GoldState(Account account)
: base(account)
{
this.Interest = 0.05;
this.LowerLimit = 1000.0;
this.UpperLimit = double.MaxValue;
}
示例9: ShareItemAsync
public override Task ShareItemAsync (Item item, Account account, CancellationToken cancellationToken)
{
Request req;
if (item.Images.Count > 0) {
req = CreateRequest ("POST", new Uri ("https://graph.facebook.com/me/photos"), account);
item.Images.First ().AddToRequest (req, "source");
var message = new StringBuilder ();
message.Append (item.Text);
foreach (var l in item.Links) {
message.AppendLine ();
message.Append (l.AbsoluteUri);
}
req.AddMultipartData ("message", message.ToString ());
}
else {
req = CreateRequest ("POST", new Uri ("https://graph.facebook.com/me/feed"), account);
req.Parameters["message"] = item.Text;
if (item.Links.Count > 0) {
req.Parameters["link"] = item.Links.First ().AbsoluteUri;
}
}
return req.GetResponseAsync (cancellationToken).ContinueWith (reqTask => {
var content = reqTask.Result.GetResponseText ();
if (!content.Contains ("\"id\"")) {
throw new SocialException ("Facebook returned an unrecognized response.");
}
});
}
示例10: TestTransferFundsToNullAccount
public void TestTransferFundsToNullAccount()
{
Account source = new Account();
source.Deposit(200.00F);
Account dest = null;
source.TransferFunds(dest, 100.00F);
}
示例11: TestDeposit
public void TestDeposit()
{
Account acc = new Account();
acc.Deposit(200.00F);
float balance = acc.Balance;
Assert.AreEqual(balance, 200F);
}
示例12: TestWithdrawNegative
public void TestWithdrawNegative()
{
Account acc = new Account();
acc.Withdraw(-3.14F);
float balance = acc.Balance;
Assert.AreEqual(balance, 1000F);
}
示例13: TestWithdraw
public void TestWithdraw()
{
Account acc = new Account();
acc.Withdraw(138.56F);
float balance = acc.Balance;
Assert.AreEqual(balance, -138.56F);
}
示例14: TestDepositNegative
public void TestDepositNegative()
{
Account acc = new Account();
acc.Deposit(-150.30F);
float balance = acc.Balance;
Assert.AreEqual(balance, -150.30F);
}
示例15: NestedObjectTypeTest
public void NestedObjectTypeTest()
{
ClearConfig();
var account = new Account();
var settings = XmlSettings<Account>.Bind(account, CONFIG_FILE);
var person = new Person();
person.Age = 3;
person.Name = "Sam";
person.Happy = false;
person.Birthdate = DateTime.Today;
account.Person = person;
account.Balance = 999;
settings.Write();
account = new Account();
settings = XmlSettings<Account>.Bind(account, CONFIG_FILE);
person = account.Person;
Assert.AreEqual(account.Balance, 999);
Assert.AreEqual(person.Age, 3);
Assert.AreEqual(person.Name, "Sam");
Assert.AreEqual(person.Happy, false);
Assert.AreEqual(person.Birthdate, DateTime.Today);
}