| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using System.ComponentModel.DataAnnotations;
- using System.ComponentModel.DataAnnotations.Schema;
- using Domain.Entities.Donations.ValueObject;
- using Domain.Entities.Members;
- namespace Domain.Entities.Donations;
- public class DonationMeta
- {
- [ForeignKey(nameof(ChannelID))]
- public virtual Channel? Channel { get; private set; }
- [ForeignKey(nameof(MemberID))]
- public virtual Member? Member { get; private set; }
- [Key]
- public int ID { get; private set; }
- public int ChannelID { get; private set; }
- public int MemberID { get; private set; }
- public int MinAmount { get; private set; } = DonationConstants.MinAmount;
- public bool IsPaused { get; private set; }
- public bool IsAccepting { get; private set; } = true;
- public bool IsAudioOnly { get; private set; }
- public bool IsVideoOnly { get; private set; }
- public DateTime? UpdatedAt { get; private set; }
- public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
- private DonationMeta() { }
- public static DonationMeta Create(int channelID, int memberID)
- {
- return new DonationMeta
- {
- ChannelID = channelID,
- MemberID = memberID
- };
- }
- public void UpdateSettings(int minAmount, bool isAccepting)
- {
- MinAmount = minAmount;
- IsAccepting = isAccepting;
- UpdatedAt = DateTime.UtcNow;
- }
- public void UpdateRemoteState(bool isPaused, bool isAudioOnly, bool isVideoOnly)
- {
- IsPaused = isPaused;
- IsAudioOnly = isAudioOnly;
- IsVideoOnly = isVideoOnly;
- UpdatedAt = DateTime.UtcNow;
- }
- public void Pause() { IsPaused = true; UpdatedAt = DateTime.UtcNow; }
- public void Resume() { IsPaused = false; UpdatedAt = DateTime.UtcNow; }
- public void StopAccepting() { IsAccepting = false; UpdatedAt = DateTime.UtcNow; }
- public void StartAccepting() { IsAccepting = true; UpdatedAt = DateTime.UtcNow; }
- }
|