public VersionInfoDTO MapToVersionInfoDTO(Revision source, VersionInfoDTO target) { if (source == null) { return(null); } target.CreatedOn = source.CreatedOn; target.LastModifiedOn = source.LastModifiedOn; target.Version = source.Version; target.CreatedByUserId = source.CreatedByUserId; target.CreatedByUserName = source.CreatedByUserName; target.LastModifiedByUserId = source.LastModifiedByUserId; target.LastModifiedByUserName = source.LastModifiedByUserName; return(target); }
/// <summary> /// Checks if source version is newer than target version and maps /// </summary> /// <param name="source"></param> /// <param name="target"></param> /// <returns></returns> public bool MapToRevision(VersionInfoDTO source, Revision target) { if (source == null) { return(false); } if (target == null) { throw new ArgumentNullException(nameof(target)); } target.Version = source.Version; if (target.CreatedOn == null) { if (source.CreatedOn != null) { target.CreatedOn = source.CreatedOn; } else { target.CreatedOn = DateTime.Now; } target.CreatedByUserId = UserId; target.CreatedByUserName = UserName; } if (target.LastModifiedOn == null || source.LastModifiedOn >= target.LastModifiedOn || ForceOldVersion) { //target.CreatedOn = source.CreatedOn; target.LastModifiedOn = source.LastModifiedOn; target.LastModifiedByUserName = UserName; target.LastModifiedByUserId = UserId; return(true); } else { return(false); } }