예제 #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Subscriber EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSubscriber(Subscriber subscriber)
 {
     base.AddObject("Subscriber", subscriber);
 }
예제 #2
0
 /// <summary>
 /// Create a new Subscriber object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 public static Subscriber CreateSubscriber(global::System.Int32 id, global::System.String email)
 {
     Subscriber subscriber = new Subscriber();
     subscriber.Id = id;
     subscriber.Email = email;
     return subscriber;
 }
예제 #3
0
        public void Subscribe(string subscr)
        {
            using (var context = new ModelContainer())
            {
                var exist = context.Subscriber.FirstOrDefault(s => s.Email == subscr);
                if (exist != null) return;

                var subscriber = new Subscriber {Email = subscr};
                context.AddToSubscriber(subscriber);
                context.SaveChanges();
            }
        }