private IEnumerable <Notification> GetNotificationsFromTasks(IEnumerable <Task> tasks)
        {
            var offerings = _commonService.GetOfferings();

            if (tasks == null || tasks.Count() == 0)
            {
                return(null);
            }

            var notifications = new List <Notification>();

            tasks
            .Select(x => x.OfferingId)
            .Distinct()
            .ToList()
            .ForEach(offeringId =>
            {
                var tasksForOffering = tasks.Where(x => x.OfferingId == offeringId);

                var matchedOfferingRecord = offerings
                                            .Where(x => x.Id == Convert.ToInt32(offeringId))
                                            .FirstOrDefault();

                var notificationBody = new ClientServiceCollectiveTaskNotificationContent
                {
                    ProjectData = tasksForOffering
                                  .Select(x => Tuple.Create <string, string, string>(x.TaskName, x.Details, x.FullName)),
                    OfferingName = matchedOfferingRecord.Description
                };

                var notificationSubject = new ClientServiceCollectiveTaskNotificationSubject
                {
                    Offering = matchedOfferingRecord.Description
                };

                var practiceEmails = matchedOfferingRecord.GetPracticeEmailGroupsAsList();

                practiceEmails = practiceEmails != null && practiceEmails.Any()
                        ? practiceEmails
                        : _commonService.GetDefaultConsultingMailboxes();

                notifications.Add(new Notification
                {
                    ToAddresses = ConfigurationManager.AppSettings[Constants.DcodeEmailId],

                    BccAddresses = practiceEmails,

                    Body = _notificationContentGenerator.GetEmailBody(notificationBody),

                    Subject = _notificationContentGenerator.GetSubject(notificationSubject)
                });
            });

            return(notifications);
        }
        private IEnumerable <Notification> GetNotificationsFromSkills(IEnumerable <string> skills)
        {
            List <Notification> notifications = null;

            if (skills != null && skills.Any())
            {
                notifications = new List <Notification>();
            }

            notifications.AddRange(skills
                                   ?.Select(skill =>
            {
                var recipients
                    = _reportingService.GetSubscribedUserForTask(skill);

                var projectInfo =
                    _reportingService.GetProjectDetailsForNewTasksAddedYesterday(skill);

                Console.WriteLine($"Number of recipients for {skill} is {(recipients != null ? recipients.Count() : 0)}");
                LogMessage($"Number of recipients for {skill} is {(recipients != null ? recipients.Count() : 0)}");

                var subjectRequest = new ClientServiceTaskNotificationSubject
                {
                    Skill = skill,
                };

                var contentRequest = new ClientServiceNotificationContent
                {
                    ProjectData = projectInfo,
                    Skill       = skill
                };

                return(new Notification
                {
                    BccAddresses = recipients?.ToList(),
                    Skill = skill,
                    ToAddresses = ConfigurationManager.AppSettings[Constants.DcodeEmailId],
                    Subject = _notificationContentType.GetSubject(subjectRequest),
                    Body = _notificationContentType.GetEmailBody(contentRequest)
                });
            }));

            Console.WriteLine($"Completed fetching recipients. Total recipient count is {notifications.Count}");
            LogMessage($"Completed fetching recipients. Total recipient count is {notifications.Count}");

            return(notifications);
        }
        private IEnumerable <Notification> GetNotificationsForNewFirmInitiatives(
            IEnumerable <Tuple <string, string, string, Int32?> > projectData)
        {
            List <Notification> notifications = null;

            if (projectData != null && projectData.Any())
            {
                notifications = new List <Notification>();
            }

            var offerings = projectData.Select(x => x.Item4).Distinct();

            var offeringsColl = _commonService.GetOfferings();

            foreach (var offering in offerings)
            {
                var bodyRequest = new FirmInitiativeTaskNotificationContent
                {
                    ProjectData  = projectData.Where(x => x.Item4 == offering),
                    OfferingName = offeringsColl.Where(x => x.Id == Convert.ToInt32(offering)).Select(x => x.Description).FirstOrDefault()
                };

                var recipients = ConfigurationManager.AppSettings["TestMode"] == "true"
                  ? _reportingService.GetDummyConsultingUsers()
                  : _reportingService.GetConsultingUsersForServiceLine(Convert.ToInt32(offering));

                recipients = recipients != null && recipients.Any()
                    ? recipients
                    : _commonService.GetDefaultConsultingMailboxes();

                notifications.Add(new Notification
                {
                    BccAddresses = recipients?.ToList(),
                    ToAddresses  = ConfigurationManager.AppSettings[Constants.DcodeEmailId],
                    Subject      = _notificationContentGenerator.GetSubject(null),
                    Body         = _notificationContentGenerator.GetEmailBody(bodyRequest)
                });
            }

            return(notifications);
        }