public static List CreateList(string name, string description, bool isMandatory) { int ordinal = GetNextOrdinal(); var list = new List() { Name = name, Description = description, Ordinal = ordinal, IsMandatory = isMandatory, IsActive = true, IsDefault = false }; using(var context = new ListContext()) { context.Lists.Add(list); context.SaveChanges(); } return list; }
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(); } } }
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; }