Skip to content

Commit

Permalink
#146 Switched BankAccountInfo to be a record
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonGeering committed Nov 24, 2020
1 parent b5b26e5 commit 75d5646
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace AdminAssistant.DomainModel.Modules.AccountsModule
{
public class BankAccountInfo : IDatabasePersistable
public record BankAccountInfo : IDatabasePersistable
{
public int BankAccountID { get; set; }
public string AccountName { get; set; } = string.Empty;
public int CurrentBalance { get; set; }
public string Symbol { get; set; } = string.Empty;
public string DecimalFormat { get; set; } = string.Empty;
public bool IsBudgeted { get; set; }
public int BankAccountID { get; init; }
public string AccountName { get; init; } = string.Empty;
public int CurrentBalance { get; init; }
public string Symbol { get; init; } = string.Empty;
public string DecimalFormat { get; init; } = string.Empty;
public bool IsBudgeted { get; init; }

public int PrimaryKey => BankAccountID;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@ public interface IBankAccountInfoBuilder
BankAccountInfo Build();
IBankAccountInfoBuilder WithTestData(int bankAccountInfoID = Constants.UnknownRecordID);
}
internal class BankAccountInfoBuilder : BankAccountInfo, IBankAccountInfoBuilder
internal class BankAccountInfoBuilder : IBankAccountInfoBuilder
{
private BankAccountInfo _bankAccountInfo = new BankAccountInfo();

public static BankAccountInfo Default(IBankAccountInfoBuilder builder) => builder.Build();

public BankAccountInfo Build() => this;
public BankAccountInfo Build() => _bankAccountInfo;

public IBankAccountInfoBuilder WithTestData(int bankAccountID = 0)
{
BankAccountID = bankAccountID;
AccountName = "A valid account name";
CurrentBalance = 0;
Symbol = "GBP";
DecimalFormat = "2.2-2";
IsBudgeted = false;

_bankAccountInfo = _bankAccountInfo with
{
BankAccountID = bankAccountID,
AccountName = "A valid account name",
CurrentBalance = 0,
Symbol = "GBP",
DecimalFormat = "2.2-2",
IsBudgeted = false
};
return this;
}
}
Expand Down

0 comments on commit 75d5646

Please sign in to comment.