profileShare

rasmusjy / splitapp-backend-modular-monolith

Read-only snapshot

No repository description.

main default branch 418 files Expires Sep 13, 2026, 9:06 AM
Trip.cs 2,277 bytes
1 using System.ComponentModel.DataAnnotations;
2 using System.ComponentModel.DataAnnotations.Schema;
3 using SplitApp.Modules.Expenses.Domain.Entities;
4 using SplitApp.Modules.Trips.Domain.Enums;
5 using SplitApp.Modules.Users.Domain.Entities;
6 using SplitApp.Shared.Kernel.Domain;
7
8 namespace SplitApp.Modules.Trips.Domain.Entities;
9
10 public class Trip : BaseEntity, IValidatableObject
11 {
12 [MaxLength(200)]
13 public string Name { get; set; } = default!;
14
15 public string? Description { get; set; }
16
17 [MaxLength(200)]
18 public string? Destination { get; set; }
19
20 public DateTime? StartDate { get; set; }
21
22 public DateTime? EndDate { get; set; }
23
24 public ETripStatus Status { get; set; } = ETripStatus.Active;
25
26 /// <summary>FK to expenses.Currency.</summary>
27 public Guid DefaultCurrencyId { get; set; }
28 /// <summary>Cross-module nav — populated by WebApp facade, never by EF (NotMapped).</summary>
29 [NotMapped] public Currency? DefaultCurrency { get; set; }
30
31 /// <summary>FK to users.AspNetUsers.</summary>
32 public Guid CreatedById { get; set; }
33 /// <summary>Cross-module nav — populated by WebApp facade, never by EF (NotMapped).</summary>
34 [NotMapped] public AppUser? CreatedBy { get; set; }
35
36 public ICollection<TripParticipant>? Participants { get; set; }
37 public ICollection<BudgetCategory>? BudgetCategories { get; set; }
38 public ICollection<TripWishlistItem>? WishlistItems { get; set; }
39 public ICollection<TripPoll>? Polls { get; set; }
40 public ICollection<TripInvitation>? Invitations { get; set; }
41
42 /// <summary>Cross-module nav — populated by WebApp facade, never by EF (NotMapped).</summary>
43 [NotMapped] public ICollection<Expense>? Expenses { get; set; }
44 /// <summary>Cross-module nav — populated by WebApp facade, never by EF (NotMapped).</summary>
45 [NotMapped] public ICollection<SettlementPlan>? SettlementPlans { get; set; }
46
47 public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
48 {
49 if (StartDate.HasValue && EndDate.HasValue && EndDate.Value < StartDate.Value)
50 {
51 yield return new ValidationResult(
52 "End date must be on or after start date.",
53 new[] { nameof(EndDate) });
54 }
55 }
56 }
57