transactions

This commit is contained in:
2025-08-24 14:18:20 +02:00
parent 1b2d95344a
commit 5777e351bf
107 changed files with 4940 additions and 1266 deletions

57
back/DataModels/User.cs Normal file
View File

@@ -0,0 +1,57 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace back.DataModels;
[Table("Users")]
public class User : IEquatable<User>
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string Id { get; set; } = null!;
[Required, EmailAddress]
public string Email { get; set; } = null!;
[Required, MinLength(8)]
public string Password { get; set; } = null!;
[Required]
public string Salt { get; set; } = null!;
public string CreatedAt { get; set; } = null!;
public virtual Person IdNavigation { get; set; } = null!;
public virtual ICollection<Gallery> Galleries { get; set; } = [];
public virtual ICollection<Gallery> GalleriesNavigation { get; set; } = [];
public virtual ICollection<Photo> Photos { get; set; } = [];
public virtual ICollection<Role> Roles { get; set; } = [];
public User() { }
public User(string id, string email, string password, DateTimeOffset createdAt)
{
Id = id;
Email = email;
Password = password;
CreatedAt = createdAt.ToString("dd-MM-yyyy HH:mm:ss zz");
}
public bool IsAdmin() => Roles.Any(r => r.IsAdmin());
public bool IsContentManager() => Roles.Any(r => r.IsContentManager());
public bool IsUser() => Roles.Any(r => r.IsUser());
public override int GetHashCode() => HashCode.Combine(Id, Email);
public override bool Equals(object? obj) => obj is User otherEvent && Equals(otherEvent);
public bool Equals(User? other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return Id == other.Id && Email == other.Email;
}
public const string SystemUserId = "00000000-0000-0000-0000-000000000001";
public static readonly User SystemUser = new(
id: SystemUserId,
email: "@system",
password: "",
createdAt: DateTime.UtcNow
);
}