Example #1
0
        /// <summary>
        /// Revises the document, resulting in a new document version incremented from the most recent version.
        /// </summary>
        /// <param name="name">
        /// The name of the new document version.
        /// </param>
        /// <returns>
        /// The new <see cref="DocumentVersion" /> for the current document.
        /// </returns>
        public DocumentVersion Revise(string name)
        {
            var versionNum      = this.DocumentVersions.Any() ? this.DocumentVersions.Max(version => version.VersionNumber) + 1 : 1;
            var documentVersion = new DocumentVersion(this, versionNum)
            {
                Name = name
            };

            this.AddVersion(documentVersion);
            return(documentVersion);
        }
Example #2
0
        /// <summary>
        /// Adds a document version to the internal linked list.
        /// </summary>
        /// <param name="version">
        /// The document version to add.
        /// </param>
        public void AddVersion([NotNull] DocumentVersion version)
        {
            if (version == null)
            {
                throw new ArgumentNullException(nameof(version));
            }

            if (this.documentVersions.Add(version) == false)
            {
                throw new BusinessException(version, "The document already contains this version.");
            }

            version.AssociateWith(this);
        }