我有这个银行 ATM 模型应用程序,它实现了一些领域驱动设计架构和工作单元模式。
这个应用程序有3个基本功能:
查看余额
订金
提取
这些是项目层:
ATM.Model(领域模型实体层)
namespace ATM.Model
{
public class BankAccount
{
public int Id { get; set; }
public string AccountName { get; set; }
public decimal Balance { get; set; }
public decimal CheckBalance()
{
return Balance;
}
public void Deposit(int amount)
{
// Domain logic
Balance += amount;
}
public void Withdraw(int amount)
{
// Domain logic
//if(amount > Balance)
//{
// throw new Exception("Withdraw amount exceed account balance.");
//}
Balance -= amount;
}
}
}
namespace ATM.Model
{
public class Transaction
{
public int Id { get; set; }
public int BankAccountId { get; set; }
public DateTime TransactionDateTime { get; set; }
public TransactionType TransactionType { get; set; }
public decimal Amount { get; set; }
}
public enum TransactionType
{
Deposit, Withdraw
}
}
慕神8447489
繁华开满天机
相关分类