private void CheckForRecepientsAndSendWeeklyReminder(List<string> listOfEmails, int churchId)
        {
            if (listOfEmails.Any())
            {
                var churchAdmins = _churchRepository.GetChurchAdmins(churchId);
                var churchAdminId = churchAdmins.Any() ? churchAdmins.First().PersonId : 1;

                //generate birthday and anniversary report
                var startDate = DateTime.Today.AddDays(2);
                var endDate = DateTime.Today.AddDays(9);
                var birthdayFileStream = _birthdayAndAnniversaryService.GetBirthdayListForADateRange(startDate, endDate, churchId);
                var anniversaryFileStream = _birthdayAndAnniversaryService.GetAnniversaryListForForADateRange(startDate, endDate, churchId);
                var birthdayFileContent = ReadToEnd(birthdayFileStream);
                var anniversaryFileContent = ReadToEnd(anniversaryFileStream);

                var birthdayAttachment = new UploadFilesResult
                {
                    Name = "BirthdayList.csv",
                    AttachmentContent = birthdayFileContent,
                    Length = birthdayFileContent.Length,
                    AttachmentContentType = "text/csv",
                    Type = "text/csv"
                };

                var anniversaryAttachment = new UploadFilesResult
                {
                    Name = "AnniversaryList.csv",
                    AttachmentContent = anniversaryFileContent,
                    Length = anniversaryFileContent.Length,
                    AttachmentContentType = "text/csv",
                    Type = "text/csv"
                };

                _emailSender.QueueEmails(
                    "Birthday and Anniversary reminders for next week",
                    "Hi, attached is a list of birthdays and anniversaries for next week",
                    listOfEmails,
                    churchAdminId,
                    churchId,
                    new List<UploadFilesResult>
                    {
                        birthdayAttachment,
                        anniversaryAttachment
                    });
            }
        }
        public ContentResult UploadFiles()
        {
            try
            {
                if (Session["AttachmentList"] == null)
                    Session["AttachmentList"] = new List<UploadFilesResult>();
                var r = (List<UploadFilesResult>)Session["AttachmentList"];

                foreach (string file in Request.Files)
                {
                    var hpf = Request.Files[file];
                    if (hpf.ContentLength == 0)
                        continue;

                    var s = hpf.InputStream;
                    var attachmentContent = new byte[hpf.ContentLength + 1];
                    s.Read(attachmentContent, 0, hpf.ContentLength);

                    var newItem = r.FirstOrDefault(i => i.Name == hpf.FileName);
                    if (newItem == null)
                    {
                        newItem = new UploadFilesResult()
                        {
                            Name = hpf.FileName,
                            Length = hpf.ContentLength,
                            AttachmentContent = attachmentContent,
                            AttachmentContentType = hpf.ContentType,
                            Type = hpf.ContentType
                        };
                        r.Add(newItem);
                    }
                    else
                    {
                        newItem.Length = hpf.ContentLength;
                        newItem.Type = hpf.ContentType;
                    }
                }
                Session["AttachmentList"] = r;
                var response = r.Aggregate("{\"list\":[", (current, item) => current + ("{\"name\":\"" + item.Name + "\"},"));
                response = response.Substring(0, response.Length - 1);
                response += "]}";
                return Content(response, "application/json");
            }
            catch (Exception ex)
            {
                return Content("{\"errorMessage\":\"" + ex.Message + "\"}", "application/json");
            }
        }