public ProviderProviderType(Provider provider, ProviderType providerType)
 {
     if (provider == null)
     {
         throw new ArgumentNullException("provider");
     }
     if (providerType == null)
     {
         throw new ArgumentNullException("ProviderType");
     }
     Provider = provider;
     ProviderType = providerType;
 }
Пример #2
0
        /// <summary>
        /// Removes the providerType.
        /// </summary>
        /// <param name="providerType">The providerType.</param>
        /// <returns>The removed providerType.</returns>
        public ProviderProviderType RemoveProviderType(ProviderType providerType)
        {
            if (providerType == null)
            {
                throw new ArgumentNullException("providerType");
            }
            var providerProviderType = ProviderProviderTypes.Single(pl => pl.ProviderType.Id == providerType.Id);
            ProviderProviderTypes.Remove(providerProviderType);

            return providerProviderType;
        }
Пример #3
0
        /// <summary>
        /// Adds a ProviderType.
        /// </summary>
        /// <param name="providerType">The ProviderType.</param>
        /// <returns>The added ProviderType.</returns>
        public ProviderProviderType AddProviderType(ProviderType providerType)
        {
            if (providerType == null)
            {
                throw new ArgumentNullException("providerType");
            }
            if (ProviderProviderTypes.Count(pl => pl.ProviderType.Id.Equals(providerType.Id)) > 0)
            {
                throw new BusinessException("The Provider Type is already associated with this provider");
            }

            var providerProviderType = new ProviderProviderType(this, providerType);
            ProviderProviderTypes.Add(providerProviderType);

            return providerProviderType;
        }
Пример #4
0
        public static void SetProviderProviderTypes(ObjectContext context, ProviderV2 source, Provider provider)
        {
            if (source.ProviderTypes == null)
                return;

            try
            {
                var existingProviderTypes = provider.ProviderProviderTypes.ToArray();
                foreach (var item in existingProviderTypes)
                    context.DeleteObject(item);

                var providerTypes = context.CreateObjectSet<ProviderType>();
                var providerProviderTypes = new List<ProviderProviderType>();

                foreach (var item in source.ProviderTypes)
                {
                    //Ensure Provider Type Exists
                    var pt = providerTypes.FirstOrDefault(s => s.Name == item.Name);
                    if (pt == null)
                    {
                        pt = new ProviderType
                        {
                            Name = item.Name,
                            IsEnabled = true
                        };
                        providerTypes.AddObject(pt);
                    }

                    var addedProviderType = new ProviderProviderType(provider, pt);
                    providerProviderTypes.Add(addedProviderType);
                }

                provider.ProviderProviderTypes = providerProviderTypes;
            }
            catch (Exception ex)
            {
                throw new BusinessException("Error processing provider types for provider '" + provider.Name + "' - " + ex.Message, ex);
            }
        }