// 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); }
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(); }
// 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); }
// 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); }
// 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); }
public void UnSubcriebeForPromotions(PromotionSender subscriber, string reason) { PromotionHandler -= subscriber; ZhalbiIPoplaki.Add(reason); }
// 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); }
public void UnsubscribeFromPromotion(PromotionSender unsubscriber, string reason) { PromotionEvent -= unsubscriber; Complaints.Add(reason); }