public static void NotificationMacker()
        {
            List <Notification> notificationList = new List <Notification>();


            using (NotificationScheduleData data = new NotificationScheduleData())
            {
                List <NotificationSchedule> notificationScheduleList = data.GetMany(x => x.StartDate.Value == x.NextRunDate.Value || x.NextRunDate.Value <= DateTime.Now).ToList();

                List <NotificationModel> notifications = data.GetMany(x => x.StartDate.Value == x.NextRunDate.Value || x.NextRunDate.Value <= DateTime.Now).Select(y =>
                                                                                                                                                                   new NotificationModel()
                {
                    Subject       = y.NotificationType.TemplateSubject,
                    Text          = y.NotificationType.TemplateText.Replace("[[username]]", y.CorrectiveActionApproval.HRRM.FirstName).Replace("[[approveDate]]", y.NextRunDate.ToString()),
                    StatusMessage = "",
                    SentStatus    = 0,
                    SentDate      = DateTime.Now,
                    SendTo        = y.CorrectiveActionApproval.HRRM.Email
                }).ToList();

                foreach (NotificationModel item in notifications)
                {
                    Notification additem = new Notification()
                    {
                        SendTo        = item.SendTo,
                        SentDate      = item.SentDate,
                        SentStatus    = item.SentStatus,
                        StatusMessage = item.StatusMessage,
                        Subject       = item.Subject,
                        Text          = item.Text
                    };
                    notificationList.Add(additem);
                }
                foreach (NotificationSchedule item in notificationScheduleList)
                {
                    DateTime newNexRunTime = item.NextRunDate.Value;

                    if (item.NextRunDate.Value >= item.StartDate.Value.AddHours(item.PeriodCount.Value * item.PeriodHours.Value))
                    {
                        item.NextRunDate = null;
                    }
                    else
                    {
                        item.NextRunDate = newNexRunTime.AddHours(item.PeriodHours.Value);
                    }

                    data.Update(item);
                }
                data.Commit();
            }

            using (NotificationData data = new NotificationData())
            {
                foreach (Notification item in notificationList)
                {
                    data.Add(item);
                }
                data.Commit();
            }
        }
        public static void SubmitForReview()
        {
            List <Notification> notificationList = new List <Notification>();

            using (NotificationScheduleData data = new NotificationScheduleData())
            {
                List <NotificationSchedule> notificationScheduleList = data.GetMany(x => x.NotificationDate != null && x.NotificationDate.Value <= DateTime.Now).ToList();


                string webBaseUrl = ConfigurationManager.AppSettings["WebBaseUrl"];
                string url        = String.Format("{0}IncidentReport/Index?reportID=", webBaseUrl);
                List <NotificationModel> notifications = data.GetMany(x => x.NotificationDate != null && x.NotificationDate.Value <= DateTime.Now).Select(y =>
                                                                                                                                                          new NotificationModel()
                {
                    Subject       = y.NotificationType.TemplateSubject,
                    Text          = y.NotificationType.TemplateText.Replace("[[username]]", y.IncidentReport.HRRM.FirstName).Replace("[[reportNumber]]", y.IncidentReport.IncidentNumber).Replace("[[reportURL]]", url + y.IncidentReportID),
                    StatusMessage = "",
                    SentStatus    = 0,
                    SentDate      = DateTime.Now,
                    SendTo        = y.IncidentReport.HRRM.Email
                }).ToList();

                foreach (NotificationModel item in notifications)
                {
                    Notification additem = new Notification()
                    {
                        SendTo        = item.SendTo,
                        SentDate      = item.SentDate,
                        SentStatus    = item.SentStatus,
                        StatusMessage = item.StatusMessage,
                        Subject       = item.Subject,
                        Text          = item.Text
                    };
                    notificationList.Add(additem);
                }

                foreach (NotificationSchedule item in notificationScheduleList)
                {
                    data.Delete(item);
                }
                data.Commit();
            }

            using (NotificationData data = new NotificationData())
            {
                foreach (Notification item in notificationList)
                {
                    data.Add(item);
                }
                data.Commit();
            }
        }