コード例 #1
0
 // This is the method that it is called to subscribe a user and it's method for reading promotions ( To get promotions from this point in time forward )
 public void SubscribeForPromotions(PromotionSender subscriber, string email)
 {
     Console.WriteLine("A person subscribed!");
     // This is how we register a method to the event
     // In business logic this is where the person wants to subsribe and they sbuscribe to the market for promotions
     PromotionUserbase += subscriber;
     Emails.Add(email);
 }
コード例 #2
0
        static void Main()
        {
            var userRepository  = new InMemoryUserRepository();
            var hotelRepository = new InMemoryHotelRepository();

            var smsMessenger   = new SmsMessenger();
            var emailMessenger = new EmailMessenger();

            var users = new User[] {
                new User("Juanma", smsMessenger, new int[] { 1, 2, 3, 4 }, hotelRepository),
                new User("Alberto", smsMessenger, new int[] { 1, 3, 5, 7 }, hotelRepository),
                new User("Emma", emailMessenger, new int[] { 2, 4, 6, 8 }, hotelRepository),
                new User("Maria", emailMessenger, new int[] { 1, 3, 4, 7, 8 }, hotelRepository)
            };

            foreach (var user in users)
            {
                userRepository.Insert(user);
            }

            var s = new PromotionSender(userRepository, hotelRepository);

            s.SendPromotionToEveryone();
        }
コード例 #3
0
 // A method that removes a subscriber method from the Promotions event
 // It also requires a reason so it can be saved in ZalbiIPoplaki as feedback
 // This subscriber expects to not get any promotions when the market sends some in the future
 public void UnsubscribeForPromotions(PromotionSender unsubscriber, string reason)
 {
     Promotions -= unsubscriber;
     ZalbiIPoplaki.Add(reason);
 }
コード例 #4
0
 // A method that accepts a subscriber method that must follow the PromotionSender delegate
 // It also takes the email of the subscriber
 // This subscriber expects to get a promotion each time the market sends one
 public void SubscribeForPromotions(PromotionSender subscriber, string email)
 {
     Promotions += subscriber;
     Emails.Add(email);
 }
コード例 #5
0
 // A method that removes a subscriber method from the Promotions event
 // It also requires a reason so it can be saved in ZalbiIPoplaki as feedback
 // This subscriber expects to not get any promotions when the market sends some in the future
 public void UnsubscribeForPromotion(PromotionSender unsubscriber, string reason)
 {
     Promotions -= unsubscriber;
     Critics.Add(reason);
 }
コード例 #6
0
 public void UnSubcriebeForPromotions(PromotionSender subscriber, string reason)
 {
     PromotionHandler -= subscriber;
     ZhalbiIPoplaki.Add(reason);
 }
コード例 #7
0
 // This is the method that it is called to unsubscribe a user and it's method for reading promotions ( To no longer get promotions )
 public void UnsubscribeForPromotions(PromotionSender subscriber, string reason)
 {
     Console.WriteLine("A person unsubscribed!");
     PromotionUserbase -= subscriber;
     SuggestionBox.Add(reason);
 }
コード例 #8
0
 public void UnsubscribeFromPromotion(PromotionSender unsubscriber, string reason)
 {
     PromotionEvent -= unsubscriber;
     Complaints.Add(reason);
 }