Skip to content

Commit

Permalink
#146 Switched Budget to be a record
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonGeering committed Dec 7, 2020
1 parent 1a0112f commit 4319790
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace AdminAssistant.DomainModel.Modules.BudgetModule
{
public class Budget : IDatabasePersistable
public record Budget : IDatabasePersistable
{
public const int BudgetNameMaxLength = Constants.NameMaxLength;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,27 @@ public interface IBudgetBuilder
IBudgetBuilder WithTestData(int budgetID = Constants.UnknownRecordID);
IBudgetBuilder WithBudgetName(string empty);
}
internal class BudgetBuilder : Budget, IBudgetBuilder
internal class BudgetBuilder : IBudgetBuilder
{
private Budget _budget = new Budget();

public static Budget Default(IBudgetBuilder builder) => builder.Build();

public Budget Build() => this;
public Budget Build() => _budget;

public IBudgetBuilder WithTestData(int budgetID = Constants.UnknownRecordID)
{
BudgetName = "Test Budget";
_budget = _budget with
{
BudgetID = budgetID,
BudgetName = "Test Budget"
};
return this;
}

public IBudgetBuilder WithBudgetName(string budgetName)
{
BudgetName = budgetName;
_budget = _budget with { BudgetName = budgetName };
return this;
}
}
Expand Down

0 comments on commit 4319790

Please sign in to comment.