Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using BlazingBudget.Domain.Aggregates.Accounts;
using BlazingBudget.Domain.Aggregates.Budgets;
using BlazingBudget.Domain.Aggregates.Expenses;
using BlazingBudget.Domain.Aggregates.Incomes;
using BlazingBudget.Domain.ValueObjects;
using BlazingBudget.Infrastructure.Persistence.EntityFramework;
using BlazingBudget.Infrastructure.Persistence.Extensions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using BlazingBudget.Domain.Aggregates.Accounts;
using BlazingBudget.Domain.Aggregates.Budgets;
using BlazingBudget.Domain.Aggregates.Debts;
using BlazingBudget.Domain.Aggregates.Expenses;
using BlazingBudget.Domain.Aggregates.Incomes;
using BlazingBudget.Domain.Aggregates.Payments;
using Mapster;

namespace BlazingBudget.Application.Mapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace BlazingBudget.Domain.Aggregates.Accounts;
using BlazingBudget.Domain.ValueObjects;

namespace BlazingBudget.Domain.Aggregates.Accounts;
public sealed class Account : Entity<AccountId>
{
public PersonName Name { get; private set; }
Expand Down
43 changes: 0 additions & 43 deletions src/Domain/BlazingBudget.Domain/Aggregates/Accounts/Email.cs

This file was deleted.

31 changes: 0 additions & 31 deletions src/Domain/BlazingBudget.Domain/Aggregates/Accounts/Password.cs

This file was deleted.

2 changes: 2 additions & 0 deletions src/Domain/BlazingBudget.Domain/Aggregates/Budgets/Budget.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using BlazingBudget.Domain.Aggregates.Accounts;
using BlazingBudget.Domain.Aggregates.Expenses;
using BlazingBudget.Domain.Aggregates.Incomes;

namespace BlazingBudget.Domain.Aggregates.Budgets;
public sealed class Budget : Entity<BudgetId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using BlazingBudget.Domain.Aggregates.Expenses;
using CSharpFunctionalExtensions;

namespace BlazingBudget.Domain.Aggregates.Budgets
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using BlazingBudget.Domain.ValueObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BlazingBudget.Domain.Aggregates.Expenses;
using BlazingBudget.Domain.Aggregates.Payments;
using BlazingBudget.Domain.ValueObjects;

namespace BlazingBudget.Domain.Aggregates.Budgets
{
Expand Down
41 changes: 0 additions & 41 deletions src/Domain/BlazingBudget.Domain/Aggregates/Budgets/Payment.cs

This file was deleted.

13 changes: 0 additions & 13 deletions src/Domain/BlazingBudget.Domain/Aggregates/Budgets/PaymentId.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Domain/BlazingBudget.Domain/Aggregates/Debts/Debt.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using BlazingBudget.Domain.Aggregates.Budgets;
using BlazingBudget.Domain.Aggregates.Payments;
using BlazingBudget.Domain.ValueObjects;
using CSharpFunctionalExtensions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using BlazingBudget.Domain.Aggregates.Budgets;
using BlazingBudget.Domain.Aggregates.Payments;
using BlazingBudget.Domain.ValueObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BlazingBudget.Domain.Aggregates.Debts
{
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using BlazingBudget.Domain.Abstractions;
using BlazingBudget.Domain.Abstractions;
using BlazingBudget.Domain.Aggregates.Payments;
using BlazingBudget.Domain.ValueObjects;

namespace BlazingBudget.Domain.Aggregates.Budgets;
namespace BlazingBudget.Domain.Aggregates.Expenses;
public class Expense : AuditableEntity<ExpenseId>
{
private Expense() { }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using StronglyTypedIds;

namespace BlazingBudget.Domain.Aggregates.Expenses;
/// <summary>
/// Expense unique identifier.
/// </summary>
[StronglyTypedId]
public readonly partial struct ExpenseId { }
Empty file.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using BlazingBudget.Domain.Abstractions;
using BlazingBudget.Domain.Abstractions;
using BlazingBudget.Domain.ValueObjects;

namespace BlazingBudget.Domain.Aggregates.Budgets;
namespace BlazingBudget.Domain.Aggregates.Incomes;
/// <summary>
/// {BudgetPlan}Income is an entity because the amount of a payment over time affects long term finances.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using StronglyTypedIds;
using StronglyTypedIds;

namespace BlazingBudget.Domain.Aggregates.Budgets;
namespace BlazingBudget.Domain.Aggregates.Incomes;
/// <summary>
/// Income unique identifier.
/// </summary>
Expand Down
Empty file.
39 changes: 39 additions & 0 deletions src/Domain/BlazingBudget.Domain/Aggregates/Payments/Payment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using BlazingBudget.Domain.ValueObjects;

namespace BlazingBudget.Domain.Aggregates.Payments;
/// <summary>
/// {BudgetPlan}Payment is an entity because the amount of a payment over time affects long term finances.
/// </summary>
public class Payment : AuditableEntity<PaymentId>
{
private Payment() { }

[JsonConstructor]
private Payment(PaymentId id, Money amount, string notes)
{
Id = id;
Amount = amount;
Notes = notes;
CreatedOn = DateTime.UtcNow;
ModifiedOn = CreatedOn;
}

public static Payment Create(Money amount, string notes = "")
{
return new Payment(new PaymentId(Guid.NewGuid()), amount, notes);
}

public void ChangeAmount(Money amount)
{
Amount = amount;
}

public void ChangeNotes(string notes)
{
Notes = notes;
}

public Money Amount { get; private set; }

public string Notes { get; set; } = string.Empty;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using StronglyTypedIds;

namespace BlazingBudget.Domain.Aggregates.Payments;
/// <summary>
/// Payment unique identifier.
/// </summary>
[StronglyTypedId]
public readonly partial struct PaymentId { }
42 changes: 42 additions & 0 deletions src/Domain/BlazingBudget.Domain/ValueObjects/Email.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using CSharpFunctionalExtensions;
using BlazingBudget.Domain.Common;

namespace BlazingBudget.Domain.ValueObjects;

public class Email : ValueObject
{
public string Value { get; private set; }

public const int MaxLength = 256;

private Email() { }

[JsonConstructor]
private Email(string value)
{
Value = value;
}

public static Result<Email> Create(string input)
{
// TODO: How do we reuse these validation rules?

if (string.IsNullOrWhiteSpace(input))
return Result.Failure<Email>(Messages.Strings.ValueIsRequired);

string email = input.Trim();

if (email.Length > MaxLength)
return Result.Failure<Email>(Messages.Strings.ValueIsTooLong);

if (!Regex.IsMatch(email, @"^(.+)@(.+)$"))
return Result.Failure<Email>(Messages.Strings.ValueIsInvalid);

return Result.Success(new Email(email));
}

protected override IEnumerable<IComparable> GetEqualityComponents()
{
yield return Value;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using CSharpFunctionalExtensions;
using BlazingBudget.Domain.ValueObjects;

namespace BlazingBudget.Domain.Aggregates.Debts;
namespace BlazingBudget.Domain.ValueObjects;
/// <summary>
/// Money owed is an amount of money still left to pay.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using BlazingBudget.Domain.ValueObjects;

namespace BlazingBudget.Domain.Aggregates.Debts;
namespace BlazingBudget.Domain.ValueObjects;
/// <summary>
/// Money paid is an amount of money paid.
/// </summary>
Expand Down
31 changes: 31 additions & 0 deletions src/Domain/BlazingBudget.Domain/ValueObjects/Password.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using CSharpFunctionalExtensions;

namespace BlazingBudget.Domain.ValueObjects;

public class Password : ValueObject
{
public string Value { get; private set; }

private Password() { }

[JsonConstructor]
private Password(string value)
{
Value = value;
}

public static Result<Password> Create(string value)
{
if (Regex.Match(value, "(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])(?=.{8,})").Success == false)
{
return Result.Failure<Password>("The password does not meet the required strength.");
}

return Result.Success(new Password(value));
}

protected override IEnumerable<object> GetEqualityComponents()
{
yield return Value;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using CSharpFunctionalExtensions;

namespace BlazingBudget.Domain.Aggregates.Accounts;
namespace BlazingBudget.Domain.ValueObjects;
public class PersonName : ValueObject
{
public string FirstName { get; private set; }
Expand Down
Loading