/// <summary> /// Update changes to the current entity compared to an input <paramref name="newdata" /> and set the entity to a proper state for updating. /// </summary> /// <param name="newdata">The "new" entity acting as the source of the changes, if any.</param> /// <returns> /// </returns> public void UpdateChanges(Announcement newdata) { int cnt = 0; if (Description != newdata.Description) { Description = newdata.Description; IsDescriptionModified = true; cnt++; } if (DispOrder != newdata.DispOrder) { DispOrder = newdata.DispOrder; IsDispOrderModified = true; cnt++; } if (Title != newdata.Title) { Title = newdata.Title; IsTitleModified = true; cnt++; } if (ExpireDate != newdata.ExpireDate) { ExpireDate = newdata.ExpireDate; IsExpireDateModified = true; cnt++; } if (LastModified != newdata.LastModified) { LastModified = newdata.LastModified; IsLastModifiedModified = true; cnt++; } IsEntityChanged = cnt > 0; }
/// <summary> /// Internal use /// </summary> public Announcement ShallowCopy(bool allData = false) { Announcement e = new Announcement(); e.IsInitializing = true; e.ID = ID; e.CreatedDate = CreatedDate; e.DispOrder = DispOrder; e.Title = Title; e.ExpireDate = ExpireDate; e.LastModified = LastModified; e.ApplicationID = ApplicationID; e.CreatedUserID = CreatedUserID; e.GroupID = GroupID; if (allData) { e.Description = Description; } e.DistinctString = GetDistinctString(true); e.IsPersisted = true; e.IsEntityChanged = false; e.IsInitializing = false; return(e); }
/// <summary> /// Internal use /// </summary> public Announcement ShallowCopy(bool allData = false) { Announcement e = new Announcement(); e.IsInitializing = true; e.ID = ID; e.CreatedDate = CreatedDate; e.DispOrder = DispOrder; e.Title = Title; e.ExpireDate = ExpireDate; e.LastModified = LastModified; e.ApplicationID = ApplicationID; e.CreatedUserID = CreatedUserID; e.GroupID = GroupID; if (allData) { e.Description = Description; } e.DistinctString = GetDistinctString(true); e.IsPersisted = true; e.IsEntityChanged = false; e.IsInitializing = false; return e; }
/// <summary> /// Merge changes inside entity <paramref name="from" /> to the entity <paramref name="to" />. Any changes in <paramref name="from" /> that is not changed in <paramref name="to" /> is updated inside <paramref name="to" />. /// </summary> /// <param name="from">The "old" entity acting as merging source.</param> /// <param name="to">The "new" entity which inherits changes made in <paramref name="from" />.</param> /// <returns> /// </returns> public static void MergeChanges(Announcement from, Announcement to) { if (to.IsPersisted) { if (from.IsDescriptionModified && !to.IsDescriptionModified) { to.Description = from.Description; to.IsDescriptionModified = true; } if (from.IsDispOrderModified && !to.IsDispOrderModified) { to.DispOrder = from.DispOrder; to.IsDispOrderModified = true; } if (from.IsTitleModified && !to.IsTitleModified) { to.Title = from.Title; to.IsTitleModified = true; } if (from.IsExpireDateModified && !to.IsExpireDateModified) { to.ExpireDate = from.ExpireDate; to.IsExpireDateModified = true; } if (from.IsLastModifiedModified && !to.IsLastModifiedModified) { to.LastModified = from.LastModified; to.IsLastModifiedModified = true; } } else { to.IsPersisted = from.IsPersisted; to.ID = from.ID; to.CreatedDate = from.CreatedDate; to.Description = from.Description; to.IsDescriptionModified = from.IsDescriptionModified; to.DispOrder = from.DispOrder; to.IsDispOrderModified = from.IsDispOrderModified; to.Title = from.Title; to.IsTitleModified = from.IsTitleModified; to.ExpireDate = from.ExpireDate; to.IsExpireDateModified = from.IsExpireDateModified; to.LastModified = from.LastModified; to.IsLastModifiedModified = from.IsLastModifiedModified; to.ApplicationID = from.ApplicationID; to.CreatedUserID = from.CreatedUserID; to.GroupID = from.GroupID; } }
/// <summary> /// Whether or not the present entity is identitical to <paramref name="other" />, in the sense that they have the same (set of) intrinsic identifiers. /// </summary> /// <param name="other">The entity to be compared to.</param> /// <returns> /// The result of comparison. /// </returns> public bool IsEntityTheSame(Announcement other) { if (other == null) return false; else return ID == other.ID; }
/// <summary> /// Whether or not the present entity is identitical to <paramref name="other" />, in the sense that they have the same (set of) primary key(s). /// </summary> /// <param name="other">The entity to be compared to.</param> /// <returns> /// The result of comparison. /// </returns> public bool IsEntityIdentical(Announcement other) { if (other == null) return false; if (ID != other.ID) return false; return true; }
/// <summary> /// Internal use /// </summary> public Announcement ShallowCopy(bool allData = false, bool preserveState = false) { Announcement e = new Announcement(); e.StartAutoUpdating = false; e.ID = ID; e.CreatedDate = CreatedDate; e.DispOrder = DispOrder; if (preserveState) { e.IsDispOrderModified = IsDispOrderModified; } else { e.IsDispOrderModified = false; } e.Title = Title; if (preserveState) { e.IsTitleModified = IsTitleModified; } else { e.IsTitleModified = false; } e.ExpireDate = ExpireDate; if (preserveState) { e.IsExpireDateModified = IsExpireDateModified; } else { e.IsExpireDateModified = false; } e.LastModified = LastModified; if (preserveState) { e.IsLastModifiedModified = IsLastModifiedModified; } else { e.IsLastModifiedModified = false; } e.ApplicationID = ApplicationID; e.CreatedUserID = CreatedUserID; e.GroupID = GroupID; if (allData) { e.Description = Description; if (preserveState) { e.IsDescriptionModified = IsDescriptionModified; } else { e.IsDescriptionModified = false; } } e.DistinctString = GetDistinctString(true); e.IsPersisted = IsPersisted; if (preserveState) { e.IsEntityChanged = IsEntityChanged; } else { e.IsEntityChanged = false; } e.StartAutoUpdating = true; return(e); }
/// <summary> /// Internal use /// </summary> public Announcement ShallowCopy(bool allData = false, bool preserveState = false, bool checkLoadState = false) { Announcement e = new Announcement(); e.StartAutoUpdating = false; e.ID = ID; e.CreatedDate = CreatedDate; e.DispOrder = DispOrder; if (preserveState) e.IsDispOrderModified = IsDispOrderModified; else e.IsDispOrderModified = false; e.Title = Title; if (preserveState) e.IsTitleModified = IsTitleModified; else e.IsTitleModified = false; e.ExpireDate = ExpireDate; if (preserveState) e.IsExpireDateModified = IsExpireDateModified; else e.IsExpireDateModified = false; e.LastModified = LastModified; if (preserveState) e.IsLastModifiedModified = IsLastModifiedModified; else e.IsLastModifiedModified = false; e.ApplicationID = ApplicationID; e.CreatedUserID = CreatedUserID; e.GroupID = GroupID; if (allData) { if (!checkLoadState || IsDescriptionLoaded) e.Description = Description; if (preserveState) e.IsDescriptionModified = IsDescriptionModified; else e.IsDescriptionModified = false; e.IsDescriptionLoaded = IsDescriptionLoaded; } e.DistinctString = GetDistinctString(true); e.IsPersisted = IsPersisted; if (preserveState) e.IsEntityChanged = IsEntityChanged; else e.IsEntityChanged = false; e.StartAutoUpdating = true; return e; }