RemoveSubscription() public method

Removes a subscription from the session.
public RemoveSubscription ( Subscription subscription ) : bool
subscription Subscription The subscription to remove.
return bool
コード例 #1
0
        /// <summary>
        /// Creates a new subscription.
        /// </summary>
        public Subscription New(Session session)
        {            
            if (session == null) throw new ArgumentNullException("session");

            Subscription subscription = new Subscription(session.DefaultSubscription);

            if (!new SubscriptionEditDlg().ShowDialog(subscription))
            {
                return null;
            }
            
            session.AddSubscription(subscription);    
            subscription.Create();

            Subscription duplicateSubscription = session.Subscriptions.FirstOrDefault(s => s.Id != 0 && s.Id.Equals(subscription.Id) && s != subscription);
            if (duplicateSubscription != null)
            {
                Utils.Trace("Duplicate subscription was created with the id: {0}", duplicateSubscription.Id);

                DialogResult result = MessageBox.Show("Duplicate subscription was created with the id: " + duplicateSubscription.Id + ". Do you want to keep it?", "Warning", MessageBoxButtons.YesNo);
                if (result == System.Windows.Forms.DialogResult.No)
                {
                    duplicateSubscription.Delete(false);
                    session.RemoveSubscription(subscription);

                    return null;
                }
            }

            Show(subscription);
            
            return subscription;
        }