using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using Abp.Json;
namespace Abp.Notifications
{
///
/// Used to store a notification subscription.
///
[Table("AbpNotificationSubscriptions")]
public class NotificationSubscriptionInfo : CreationAuditedEntity, IMayHaveTenant
{
///
/// Tenant id of the subscribed user.
///
public virtual int? TenantId { get; set; }
///
/// User Id.
///
public virtual long UserId { get; set; }
///
/// Notification unique name.
///
[StringLength(NotificationInfo.MaxNotificationNameLength)]
public virtual string NotificationName { get; set; }
///
/// Gets/sets entity type name, if this is an entity level notification.
/// It's FullName of the entity type.
///
[StringLength(NotificationInfo.MaxEntityTypeNameLength)]
public virtual string EntityTypeName { get; set; }
///
/// AssemblyQualifiedName of the entity type.
///
[StringLength(NotificationInfo.MaxEntityTypeAssemblyQualifiedNameLength)]
public virtual string EntityTypeAssemblyQualifiedName { get; set; }
///
/// Gets/sets primary key of the entity, if this is an entity level notification.
///
[StringLength(NotificationInfo.MaxEntityIdLength)]
public virtual string EntityId { get; set; }
///
/// Initializes a new instance of the class.
///
public NotificationSubscriptionInfo()
{
}
///
/// Initializes a new instance of the class.
///
public NotificationSubscriptionInfo(Guid id, int? tenantId, long userId, string notificationName, EntityIdentifier entityIdentifier = null)
{
Id = id;
TenantId = tenantId;
NotificationName = notificationName;
UserId = userId;
EntityTypeName = entityIdentifier == null ? null : entityIdentifier.Type.FullName;
EntityTypeAssemblyQualifiedName = entityIdentifier == null ? null : entityIdentifier.Type.AssemblyQualifiedName;
EntityId = entityIdentifier == null ? null : entityIdentifier.Id.ToJsonString();
}
}
}