/// <summary> /// Adds a language. /// </summary> /// <param name="language">The language.</param> /// <returns>The added language.</returns> public ProviderLanguage AddLanguage(Language language) { if (language == null) { throw new ArgumentNullException("language"); } if (ProviderLanguages.Count(pl => pl.Language.Id.Equals(language.Id)) > 0) { throw new BusinessException(string.Format(CultureInfo.CurrentCulture, "The language ({0}) is already associated with this provider", language.Name)); } var providerLanguage = new ProviderLanguage(this, language, false); ProviderLanguages.Add(providerLanguage); if (ProviderLanguages.Count == 1) { SetPrimaryLanguage(providerLanguage); } return providerLanguage; }
/// <summary> /// Sets the primary provider language. /// </summary> /// <param name="providerLanguage">The provider specialty.</param> public void SetPrimaryLanguage(ProviderLanguage providerLanguage) { providerLanguage.IsPrimary = true; ProviderLanguages.Where(ps => ps.Language.Id != providerLanguage.Language.Id) .ToList() .ForEach(pl => pl.IsPrimary = false); }
/// <summary> /// Sets the language as fluent for the provider /// </summary> /// <param name="providerLanguage">The provider specialty.</param> /// <param name="isFluent">The flag for if the language is fluent.</param> public static void SetFluentLanguage(ProviderLanguage providerLanguage, bool isFluent) { if (providerLanguage.IsPrimary && isFluent) { throw new BusinessException("Primary Language cannot be marked as fluent for the provider."); } providerLanguage.IsFluent = isFluent; }