public Facility TakeSnapFrom(MasterFacility snapMfl) { var fac = this; fac.SnapshotDate = DateTime.Now; fac.SiteCode = snapMfl.Id; fac.SnapshotSiteCode = snapMfl.SnapshotSiteCode; fac.SnapshotVersion = snapMfl.SnapshotVersion; return(fac); }
public MasterFacility TakeSnap(List <MasterFacility> mflSnaps) { MasterFacility lastSnap = null; if (mflSnaps.Any()) { lastSnap = mflSnaps .OrderBy(x => x.SnapshotDate) .ThenBy(x => x.SnapshotVersion) .Last(); } var snapVersion = null == lastSnap ? 1 : lastSnap.GetNextSnapshotVersion(); var snapSiteCode = Convert.ToInt32($"-{100 + snapVersion}{Id}"); var fac = this; fac.SnapshotSiteCode = Id; fac.Id = snapSiteCode; fac.SnapshotDate = DateTime.Now; fac.SnapshotVersion = snapVersion; return(fac); }