using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; using gehGassi.Domain.Localization; namespace gehGassi.Domain.Base { /// /// Basisklasse für eine Entität welche über Synchronisierungs-Eigenschaften verfügt /// public class SyncEntity : ISyncEntity { /// /// Guid als String - wird als Key verwendet. /// Hier so gelöst, da nicht alle Datenbanken über Guids verfügen /// [Key] [MaxLength(128)] public string Id { get; set; } /// /// Index für schnelle Suche. /// Muss via Fluent-API im DB-Context gesetzt werden! /// [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public long Index { get; set; } /// /// Eindeutiger Versions-Identifikator für diese Entität. Muss bei jeder Schreib-Operation gesetzt werden /// [Timestamp] public byte[] Version { get; set; } /// /// Datum und Uhrzeit inkl. Zeitzone wann die letzte Aktualisierung stattgefunden hat. /// public DateTimeOffset UpdatedAt { get; set; } = DateTimeOffset.UtcNow; /// /// Gibt an ob diese Entität gelöscht wurde /// public bool Deleted { get; set; } /// Indicates whether the current object is equal to another object of the same type. /// An object to compare with this object. /// /// if the current object is equal to the parameter; otherwise, . public bool Equals(ISyncEntity other) => other != null && Id == other.Id && UpdatedAt == other.UpdatedAt && Deleted == other.Deleted && Version.SequenceEqual(other.Version); } /// /// Basisklasse für eine Entität welche über Synchronisierungs-Eigenschaften und Übersetzungen verfügt /// public class SyncEntityLocalizable : LocalizableBase, ISyncEntity { /// /// Guid als String - wird als Key verwendet. /// Hier so gelöst, da nicht alle Datenbanken über Guids verfügen /// [Key] [MaxLength(128)] public string Id { get; set; } /// /// Index für schnelle Suche. /// Muss via Fluent-API im DB-Context gesetzt werden! /// [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public long Index { get; set; } /// /// Eindeutiger Versions-Identifikator für diese Entität. Muss bei jeder Schreib-Operation gesetzt werden /// [Timestamp] public byte[] Version { get; set; } /// /// Datum und Uhrzeit inkl. Zeitzone wann die letzte Aktualisierung stattgefunden hat. /// public DateTimeOffset UpdatedAt { get; set; } = DateTimeOffset.UtcNow; /// /// Gibt an ob diese Entität gelöscht wurde /// public bool Deleted { get; set; } /// Indicates whether the current object is equal to another object of the same type. /// An object to compare with this object. /// /// if the current object is equal to the parameter; otherwise, . public bool Equals(ISyncEntity other) => other != null && Id == other.Id && UpdatedAt == other.UpdatedAt && Deleted == other.Deleted && Version.SequenceEqual(other.Version); } /// /// Basisklasse für eine Entität welche über Synchronisierungs-Eigenschaften verfügt für Views /// public class SyncEntityVw : ISyncEntity { /// /// Guid als String - wird als Key verwendet. /// Hier so gelöst, da nicht alle Datenbanken über Guids verfügen /// public string Id { get; set; } /// /// Index für schnelle Suche. /// Muss via Fluent-API im DB-Context gesetzt werden! /// public long Index { get; set; } /// /// Eindeutiger Versions-Identifikator für diese Entität. Muss bei jeder Schreib-Operation gesetzt werden /// public byte[] Version { get; set; } /// /// Datum und Uhrzeit inkl. Zeitzone wann die letzte Aktualisierung stattgefunden hat. /// public DateTimeOffset UpdatedAt { get; set; } /// /// Gibt an ob diese Entität gelöscht wurde /// public bool Deleted { get; set; } /// Indicates whether the current object is equal to another object of the same type. /// An object to compare with this object. /// /// if the current object is equal to the parameter; otherwise, . public bool Equals(ISyncEntity other) => other != null && Id == other.Id && UpdatedAt == other.UpdatedAt && Deleted == other.Deleted && Version.SequenceEqual(other.Version); } /// /// Basisklasse für eine Entität welche über Synchronisierungs-Eigenschaften und Übersetzungen verfügt für Views /// public class SyncEntityLocalizableVw : LocalizableBase, ISyncEntity { /// /// Guid als String - wird als Key verwendet. /// Hier so gelöst, da nicht alle Datenbanken über Guids verfügen /// public string Id { get; set; } /// /// Index für schnelle Suche. /// Muss via Fluent-API im DB-Context gesetzt werden! /// public long Index { get; set; } /// /// Eindeutiger Versions-Identifikator für diese Entität. Muss bei jeder Schreib-Operation gesetzt werden /// public byte[] Version { get; set; } /// /// Datum und Uhrzeit inkl. Zeitzone wann die letzte Aktualisierung stattgefunden hat. /// public DateTimeOffset UpdatedAt { get; set; } /// /// Gibt an ob diese Entität gelöscht wurde /// public bool Deleted { get; set; } /// Indicates whether the current object is equal to another object of the same type. /// An object to compare with this object. /// /// if the current object is equal to the parameter; otherwise, . public bool Equals(ISyncEntity other) => other != null && Id == other.Id && UpdatedAt == other.UpdatedAt && Deleted == other.Deleted && Version.SequenceEqual(other.Version); } }