Skip to content

Commit

Permalink
Added immutable entities
Browse files Browse the repository at this point in the history
  • Loading branch information
MarouaneDV committed Sep 15, 2024
1 parent f1e7862 commit a882eda
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions MaruanBH.Domain/Entities/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace MaruanBH.Domain.Entities
/// </summary>
public class Account
{
public Guid Id { get; set; }
public Guid CustomerId { get; set; } // foreign key
public decimal InitialCredit { get; set; }
public Guid Id { get; init; }
public Guid CustomerId { get; init; } // foreign key
public decimal InitialCredit { get; init; }

public Account(Guid customerId, decimal initialCredit)
{
Expand Down
10 changes: 6 additions & 4 deletions MaruanBH.Domain/Entities/Customer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ namespace MaruanBH.Domain.Entities
/// </summary>
public class Customer
{
public Guid Id { get; init; } = Guid.NewGuid();
public string Name { get; init; } = string.Empty;
public string Surname { get; init; } = string.Empty;
public Guid Id { get; init; }
public string Name { get; init; }
public string Surname { get; init; }
public decimal Balance { get; init; }
public IReadOnlyList<Transaction> Transactions { get; init; } = new List<Transaction>();
public IReadOnlyList<Transaction> Transactions { get; init; }

public Customer(string name, string surname, decimal balance)
{
Id = Guid.NewGuid();
Name = name;
Surname = surname;
Balance = balance;
Transactions = new List<Transaction>();
}
}
}

0 comments on commit a882eda

Please sign in to comment.