using DTS.Common.Interface.Groups; using DTS.Common.Interface.Groups.GroupList; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Data; namespace DTS.Common.Classes.Groups { /// /// represents a record of a channel in the db /// /// public class GroupDbRecord : Base.BasePropertyChanged, IGroupDbRecord { protected int _id = -1; /// /// The database id of the Channel /// [Key] public int Id { get => _id; set => SetProperty(ref _id, value, "Id"); } public string SerialNumber { get; set; } public string Picture { get; set; } public string DisplayName { get; set; } public string Description { get; set; } public bool Embedded { get; set; } public DateTime LastModified { get; set; } public string LastModifiedBy { get; set; } public int? StaticGroupId { get; set; } public string ExtraProperties { get; set; } public GroupDbRecord() { } public GroupDbRecord(IGroupDbRecord copy) { Id = copy.Id; SerialNumber = copy.SerialNumber; Picture = copy.Picture; DisplayName = copy.DisplayName; Description = copy.Description; Embedded = copy.Embedded; LastModified = copy.LastModified; LastModifiedBy = copy.LastModifiedBy; StaticGroupId = copy.StaticGroupId; ExtraProperties = copy.ExtraProperties; } public GroupDbRecord(IGroup copy, List> extraProperties) { Id = copy.Id; SerialNumber = copy.Name; Picture = ""; DisplayName = copy.DisplayName; Description = copy.Description; Embedded = copy.Embedded; LastModified = copy.LastModified; LastModifiedBy = copy.LastModifiedBy; StaticGroupId = copy.StaticGroupId; ExtraProperties = JsonConvert.SerializeObject(extraProperties); } public GroupDbRecord(IDataReader reader) { Id = Utility.GetInt(reader, "Id", -1); SerialNumber = Utility.GetString(reader, "SerialNumber"); Picture = Utility.GetString(reader, "Picture"); DisplayName = Utility.GetString(reader, "DisplayName"); Description = Utility.GetString(reader, "Description"); Embedded = Utility.GetBool(reader, "Embedded"); LastModified = Utility.GetDateTime(reader, "LastModified", DateTime.MinValue); LastModifiedBy = Utility.GetString(reader, "LastModifiedBy"); StaticGroupId = Utility.GetNullableInt(reader, "StaticGroupId"); ExtraProperties = Utility.GetString(reader, "ExtraProperties"); } } }