DonationAlertAttempt.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.ComponentModel.DataAnnotations;
  2. using System.ComponentModel.DataAnnotations.Schema;
  3. namespace Domain.Entities.Donations;
  4. public class DonationAlertAttempt
  5. {
  6. [ForeignKey(nameof(DonationID))]
  7. public virtual Donation Donation { get; private set; } = default!;
  8. [ForeignKey(nameof(DonationAlertID))]
  9. public virtual DonationAlert DonationAlert { get; private set; } = default!;
  10. [Key]
  11. public int ID { get; private set; }
  12. public int DonationID { get; private set; }
  13. public int DonationAlertID { get; private set; }
  14. public string? IpAddress { get; private set; }
  15. public string? UserAgent { get; private set; }
  16. public DateTime SentAt { get; private set; } = DateTime.UtcNow;
  17. private DonationAlertAttempt() { }
  18. public static DonationAlertAttempt Create(
  19. int donationID,
  20. int donationAlertID,
  21. string? ipAddress = null,
  22. string? userAgent = null
  23. )
  24. {
  25. return new DonationAlertAttempt
  26. {
  27. DonationID = donationID,
  28. DonationAlertID = donationAlertID,
  29. IpAddress = ipAddress,
  30. UserAgent = userAgent
  31. };
  32. }
  33. }