Beispiel #1
0
        public void UnsubscribeUser(MembershipUser user)
        {
            var helper = new ListManager();
            helper.SendUnsubscribeCommand(user, this);

            using (var context = new ListContext())
            {
                var sub = (from v in context.Subscriptions
                           where v.Username == user.UserName && v.ListId == this.ListId
                           select v).FirstOrDefault();
                if(sub != null)
                {
                    context.Subscriptions.Remove(sub);
                    context.SaveChanges();
                }
            }
        }
Beispiel #2
0
        public Subscription SubscribeUser(MembershipUser user)
        {
            var helper = new ListManager();
            helper.SendSubscribeCommand(user, this);

            // subscribe if we're not subscribed...
            var sub = GetSubscription(user);
            if(sub == null)
            {
                using (var context = new ListContext())
                {
                    sub = new Subscription()
                    {
                        ListId = this.ListId,
                        Username = user.UserName
                    };
                    context.Subscriptions.Add(sub);
                    context.SaveChanges();
                }
            }

            return sub;
        }