Exemple #1
0
        public void handle(string message, Events events)
        {
            NotificationFinder notificationFinder = new NotificationFinder();
            var eventsSms = notificationFinder.FindAvailableEventsByMode()
                            .Where(e => e.NoifyBySms == true && e.NotificationTypeId == events.NotificationTypeId).Select(e => e.employee).Distinct().ToList();
            var eventsEmail = notificationFinder.FindAvailableEventsByMode()
                              .Where(e => e.NotifyByEmail == true && e.NotificationTypeId == events.NotificationTypeId).Select(e => e.employee).Distinct().ToList();
            var eventsInApp = notificationFinder.FindAvailableEventsByMode()
                              .Where(e => e.NotifyInApp == true && e.NotificationTypeId == events.NotificationTypeId).Select(e => e.employee).Distinct().ToList();

            NotificationManager notificationManager;


            if (eventsSms.Count > 0)
            {
                notificationManager = new NotificationManager(new NotifyBySms());
                notificationManager.NotificationInterface(message, eventsSms);
            }
            Console.WriteLine("-------------------------");
            if (eventsEmail.Count > 0)
            {
                notificationManager = new NotificationManager(new NotifyByEmail());
                notificationManager.NotificationInterface(message, eventsEmail);
            }
            Console.WriteLine("-------------------------");
            if (eventsInApp.Count > 0)
            {
                notificationManager = new NotificationManager(new InAppNotify());
                notificationManager.NotificationInterface(message, eventsInApp);
            }
        }
        public void sendNotification(string message, List <Employee> employee)
        {
            NotificationFinder notificationFinder = new NotificationFinder();


            foreach (var emp in employee)
            {
                Console.WriteLine("Hi {0}, {1}", emp.EmployeeName, message);
            }
        }
        static void Main(string[] args)
        {
            NotificationFinder notificationFinder = new NotificationFinder();
            var notificationTypes = notificationFinder.FindAvailableEvents(DateTime.Now).GroupBy(e => e.NotificationTypeId);

            INotificationHandler notificationHandler;

            foreach (var group in notificationTypes)
            {
                List <Events> events = new List <Events>();
                Console.WriteLine(group.Key);
                foreach (var g in group)
                {
                    events.Add(g);
                }

                notificationHandler = NotificationHandlerFactory.GetHandler(group.Key);
                notificationHandler.create(events);
            }
            Console.ReadLine();
        }
Exemple #4
0
 public JsonResult ReadNotification(long id)
 {
     return(Json(new { result = NotificationFinder.Read(id) }));
 }