redo
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
using MCVIngenieros.Transactional.Abstractions.Interfaces;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace back.DataModels;
|
||||
|
||||
public record PermissionDto
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
}
|
||||
|
||||
[Table("Permissions")]
|
||||
public partial class Permission: IEquatable<Permission>
|
||||
public partial class Permission : IEntity<Permission>
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public string Id { get; set; } = null!;
|
||||
@@ -26,6 +32,32 @@ public partial class Permission: IEquatable<Permission>
|
||||
Id == other.Id || GetHashCode() == other.GetHashCode();
|
||||
}
|
||||
|
||||
public bool IsNull => this is null;
|
||||
|
||||
public object Clone() => (Permission)MemberwiseClone();
|
||||
|
||||
public int CompareTo(object? obj)
|
||||
{
|
||||
if (obj is null) return 1;
|
||||
if (obj is not Permission other) throw new ArgumentException("Object is not a Person");
|
||||
return CompareTo(other);
|
||||
}
|
||||
|
||||
public int CompareTo(Permission? other)
|
||||
{
|
||||
if (other is null) return 1;
|
||||
if (ReferenceEquals(this, other)) return 0;
|
||||
return string.Compare(Id, other.Id, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public PermissionDto ToDto()
|
||||
{
|
||||
return new PermissionDto
|
||||
{
|
||||
Id = Id
|
||||
};
|
||||
}
|
||||
|
||||
// Static permissions
|
||||
public static readonly Permission ViewContentPermission = new() { Id = "1", Name = "VIEW_CONTENT", Description = "Permission to view content" };
|
||||
public static readonly Permission LikeContentPermission = new() { Id = "2", Name = "LIKE_CONTENT", Description = "Permission to like content" };
|
||||
|
||||
Reference in New Issue
Block a user