Skip to content

Commit

Permalink
#146 Switched BankAccountType to use record
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonGeering committed Nov 20, 2020
1 parent b77dac4 commit 02adae4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace AdminAssistant.DomainModel.Modules.AccountsModule
{
public class BankAccountType : IDatabasePersistable
public record BankAccountType : IDatabasePersistable
{
public const int DescriptionMaxLength = Constants.DescriptionMaxLength;

public int BankAccountTypeID { get; set; }
public string Description { get; set; } = string.Empty;
public int BankAccountTypeID { get; init; } = Constants.UnknownRecordID;
public string Description { get; init; } = string.Empty;
public int PrimaryKey => BankAccountTypeID;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@ public interface IBankAccountTypeBuilder
IBankAccountTypeBuilder WithTestData(int bankAccountTypeID = Constants.NewRecordID);
IBankAccountTypeBuilder WithDescription(string description);
}
internal class BankAccountTypeBuilder : BankAccountType, IBankAccountTypeBuilder
internal class BankAccountTypeBuilder : IBankAccountTypeBuilder
{
private BankAccountType _bankAccountType = new BankAccountType();
public static BankAccountType Default(IBankAccountTypeBuilder builder) => builder.Build();

public BankAccountType Build() => this;
public BankAccountType Build() => _bankAccountType;

public IBankAccountTypeBuilder WithTestData(int bankAccountTypeID = Constants.NewRecordID)
{
BankAccountTypeID = bankAccountTypeID;
Description = "A valid BankAccountType description";
_bankAccountType = _bankAccountType with
{
BankAccountTypeID = bankAccountTypeID,
Description = "A valid BankAccountType description"
};
return this;
}

public IBankAccountTypeBuilder WithDescription(string description)
{
Description = description;
_bankAccountType = _bankAccountType with { Description = description };
return this;
}
}
Expand Down

0 comments on commit 02adae4

Please sign in to comment.