예제 #1
0
        /// <summary>
        /// Sets type to the association found by id.
        /// </summary>
        /// <param name="associationId">Id of the association for updating.</param>
        /// <param name="type">Type from list of known types.</param>
        /// <param name="offerType">New type name suggested by the expert.</param>
        public virtual void SetTypeForAssociation(
            Guid associationId,
            [NotNull] NotionType type,
            [CanBeNull] string offerType)
        {
            if (associationId == Guid.Empty)
            {
                throw new ArgumentException("Id should not be empty", nameof(associationId));
            }
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            var expertAssociation = Associations.SingleOrDefault(m => m.Id == associationId);

            if (expertAssociation == null)
            {
                throw new InvalidOperationException(
                          $"It's not possible set types for non existence association {associationId} for expert {this}");
            }

            expertAssociation.UpdateTypes(type, offerType);
        }