Skip to content

Commit

Permalink
Removed PaymentInstruction:ExpenseApplication/Infrastructure/Entities…
Browse files Browse the repository at this point in the history
…/Expense.cs
  • Loading branch information
rsemihkoca committed Jan 21, 2024
1 parent 9dcd45b commit b395ee4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ExpenseApplication/Infrastructure/Entities/Expense.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ public class Expense : BaseEntity
public string Description { get; set; } // (from User)
public DateTime CreationDate { get; set; }
public DateTime LastUpdateTime { get; set; }

public PaymentRequestStatus PaymentStatus { get; set; } = PaymentRequestStatus.Pending;// (Pending, Completed, Failed)
public DateTime? PaymentDate { get; set; } = null; // (if Status is Completed)
public string PaymentDescription { get; set; } = "";// (if Status is Rejected)
public virtual User User { get; set; }
public virtual ExpenseCategory ExpenseCategory { get; set; }
public virtual PaymentInstruction PaymentInstruction { get; set; }
}

public class ExpenseRequestConfiguration : IEntityTypeConfiguration<Expense>
Expand Down Expand Up @@ -54,6 +57,8 @@ public void Configure(EntityTypeBuilder<Expense> builder)
builder.Property(e => e.CreationDate).IsRequired();

builder.Property(e => e.LastUpdateTime).IsRequired();

builder.Property(e => e.PaymentStatus).IsRequired().HasConversion<string>();

builder.HasOne(e => e.User)
.WithMany(u => u.ExpenseRequests)
Expand All @@ -64,12 +69,7 @@ public void Configure(EntityTypeBuilder<Expense> builder)
.WithMany()
.HasForeignKey(e => e.CategoryId);
// .OnDelete(DeleteBehavior.Restrict); // Prevent deletion of ExpenseCategory if it is referenced by an Expense

builder.HasOne(e => e.PaymentInstruction)
.WithOne(e => e.Expense)
.HasForeignKey<PaymentInstruction>(p => p.ExpenseRequestId);

// .OnDelete(DeleteBehavior.Restrict); // Prevent deletion of PaymentInstruction if it is referenced by an Expense



}
Expand Down

0 comments on commit b395ee4

Please sign in to comment.