diff --git a/Amen/Controllers/NotificationController.cs b/Amen/Controllers/NotificationController.cs index ac317ae..b892add 100644 --- a/Amen/Controllers/NotificationController.cs +++ b/Amen/Controllers/NotificationController.cs @@ -31,7 +31,6 @@ namespace Amen.Controllers ManageUrl = controllerHelper.Absolute(this.Url, Url.Action("Index", "Manage", new { affiliatekey = prayer.Affiliate.Key })) }; ViewBag.LogoUrl = controllerHelper.Absolute(this.Url, Url.Content("~/Content/Images/amen-logo-flyin.gif")); - return View("~/Views/Email/Prayed.cshtml", model); } @@ -47,7 +46,6 @@ namespace Amen.Controllers ManageUrl = controllerHelper.Absolute(this.Url, Url.Action("Index", "Manage", new { affiliatekey = prayer.Affiliate.Key })) }; ViewBag.LogoUrl = controllerHelper.Absolute(this.Url, Url.Content("~/Content/Images/amen-logo-flyin.gif")); - return View("~/Views/Email/PrayerSubmitted.cshtml", model); } @@ -64,7 +62,6 @@ namespace Amen.Controllers ManageUrl = controllerHelper.Absolute(this.Url, Url.Action("Index", "Manage", new { affiliatekey = prayer.Affiliate.Key })) }; ViewBag.LogoUrl = controllerHelper.Absolute(this.Url, Url.Content("~/Content/Images/amen-logo-flyin.gif")); - return View("~/Views/Email/NoteSent.cshtml", model); } @@ -82,7 +79,6 @@ namespace Amen.Controllers NotificationTypeMessage = string.Format("A new {0} has been submitted.", prayer.IsPraise ? "Praise" : "Prayer") }; ViewBag.LogoUrl = controllerHelper.Absolute(this.Url, Url.Content("~/Content/Images/amen-logo-flyin.gif")); - return View("~/Views/Email/AdminNotification.cshtml", model); } @@ -206,34 +202,21 @@ namespace Amen.Controllers var model = new PrayerEmailViewModel(); model.Title = prayer.Summary; model.Subject = "We are praying for you!"; - if (appUser != null) - { - model.To = appUser.Email; - } - else - { - model.To = prayer.AnonymousEmail; - } model.DetailUrl = controller.controllerHelper.Absolute(urlHelper, urlHelper.Action("Detail", "Prayer", new { id = prayer.Id, affiliatekey = affiliate.Key })); model.ManageUrl = controller.controllerHelper.Absolute(urlHelper, urlHelper.Action("Index", "Manage", new { affiliatekey = affiliate.Key })); model.IsUserLoggedIn = !string.IsNullOrEmpty(prayer.ApplicationUserId); model.IsPraise = prayer.IsPraise; - if (CanSendEmail(affiliate, ref appUser, prayer, false, true)) + if (CanSendEmail(affiliate, ref appUser, prayer, false, true) && (prayer.ContactPreference == "email" || prayer.ContactPreference == "any")) { - if (prayer.ContactPreference == "email" || prayer.ContactPreference == "any") - { - var body = ControllerHelper.RenderViewToString(controller.ControllerContext, "~/Views/Email/PrayerSubmitted.cshtml", model); - SendEmailMessage(model.To, model.Subject, body); - } + var body = ControllerHelper.RenderViewToString(controller.ControllerContext, "~/Views/Email/PrayerSubmitted.cshtml", model); + SendEmailMessage(prayer.AnonymousEmail, model.Subject, body); } - if (CanSendText(affiliate, ref appUser, prayer)) + if (CanSendText(affiliate, ref appUser, prayer) && (prayer.ContactPreference == "phone" || prayer.ContactPreference == "any")) { - if (prayer.ContactPreference == "phone" || prayer.ContactPreference == "any") - { - SendSmsMessage(affiliate.TwilioSID, affiliate.TwilioAuthToken, affiliate.TwilioPhoneNumber, appUser.PhoneNumber, string.Format("We are praying for you! {0}", model.DetailUrl)); - } + var message = string.Format("We are praying for you! {0}", model.DetailUrl); + SendSmsMessage(affiliate.TwilioSID, affiliate.TwilioAuthToken, affiliate.TwilioPhoneNumber, prayer.AnonymousPhone, message); } if (affiliate != null @@ -247,9 +230,7 @@ namespace Amen.Controllers { var controller2 = GetBaseController(affiliate); controller2.ViewBag.LogoUrl = controller2.controllerHelper.Absolute(urlHelper, urlHelper.Content("~/Content/Images/amen-logo-flyin.gif")); - var adminModel = new AdminEmailViewModel(); - adminModel.PrayerTitle = prayer.Summary; adminModel.PrayerContent = prayer.Content; adminModel.Subject = string.Format("Admin Notification: {0} Requested", prayer.IsPraise ? "Praise" : "Prayer"); @@ -261,9 +242,7 @@ namespace Amen.Controllers } adminModel.DetailUrl = controller2.controllerHelper.Absolute(urlHelper, urlHelper.Action("Detail", "Prayer", new { id = prayer.Id, affiliatekey = affiliate.Key, isPraise = prayer.IsPraise })); adminModel.ManageUrl = controller2.controllerHelper.Absolute(urlHelper, urlHelper.Action("Index", "Group")); - var body = ControllerHelper.RenderViewToString(controller2.ControllerContext, "~/Views/Email/AdminNotification.cshtml", adminModel); - SendEmailMessage(adminModel.To, adminModel.Subject, body); } } @@ -274,51 +253,37 @@ namespace Amen.Controllers var controller = GetBaseController(affiliate); model.DetailUrl = controller.controllerHelper.Absolute(urlHelper, urlHelper.Action("Detail", "Prayer", new { id = prayer.Id, affiliatekey = affiliate.Key })); model.ManageUrl = controller.controllerHelper.Absolute(urlHelper, urlHelper.Action("Index", "Manage", new { affiliatekey = affiliate.Key })); + model.Title = prayer.Summary; - if (CanSendText(affiliate, ref appUser, prayer)) + if (CanSendEmail(affiliate, ref appUser, prayer) && (prayer.ContactPreference == "email" || prayer.ContactPreference == "any")) { - if (prayer.ContactPreference == "phone" || prayer.ContactPreference == "any") - { - SendSmsMessage(affiliate.TwilioSID, affiliate.TwilioAuthToken, affiliate.TwilioPhoneNumber, appUser.PhoneNumber, string.Format("Someone just prayed for you! {0}", model.DetailUrl)); - } + controller.ViewBag.LogoUrl = controller.controllerHelper.Absolute(urlHelper, urlHelper.Content("~/Content/Images/amen-logo-flyin.gif")); + var subject = !string.IsNullOrEmpty(affiliate.SendMessagePrayed) ? affiliate.SendMessagePrayed : "Someone just prayed for you!"; + var body = ControllerHelper.RenderViewToString(controller.ControllerContext, "~/Views/Email/Prayed.cshtml", model); + SendEmailMessage(prayer.AnonymousEmail, subject, body); } - if (CanSendEmail(affiliate, ref appUser, prayer)) + if (CanSendText(affiliate, ref appUser, prayer) && (prayer.ContactPreference == "phone" || prayer.ContactPreference == "any")) { - if (prayer.ContactPreference == "email" || prayer.ContactPreference == "any") - { - controller.ViewBag.LogoUrl = controller.controllerHelper.Absolute(urlHelper, urlHelper.Content("~/Content/Images/amen-logo-flyin.gif")); - - model.Title = prayer.Summary; - model.Subject = !string.IsNullOrEmpty(affiliate.SendMessagePrayed) ? affiliate.SendMessagePrayed : "Someone just prayed for you!"; - model.To = appUser.Email; - - var body = ControllerHelper.RenderViewToString(controller.ControllerContext, "~/Views/Email/Prayed.cshtml", model); - - SendEmailMessage(model.To, model.Subject, body); - } + var message = string.Format("Someone just prayed for you! {0}", model.DetailUrl); + SendSmsMessage(affiliate.TwilioSID, affiliate.TwilioAuthToken, affiliate.TwilioPhoneNumber, prayer.AnonymousPhone, message); } } public static void NotifyNoteSent(UrlHelper urlHelper, Affiliate affiliate, ApplicationUser appUser, Prayer prayer, PrayerNote note) { - if (!CanSendEmail(affiliate, ref appUser, prayer, true) || !prayer.EnableEmailNote) - return; - + if (!CanSendEmail(affiliate, ref appUser, prayer, true) || !prayer.EnableEmailNote) { return; } var controller = GetBaseController(affiliate); controller.ViewBag.LogoUrl = controller.controllerHelper.Absolute(urlHelper, urlHelper.Content("~/Content/Images/amen-logo-flyin.gif")); - var model = new PrayerEmailViewModel(); model.Title = prayer.Summary; model.NoteText = note.NoteText; model.Subject = !string.IsNullOrEmpty(affiliate.SendMessagePrayed) ? affiliate.SendMessageNote : "A note from Amen"; - model.To = appUser.Email; model.DetailUrl = controller.controllerHelper.Absolute(urlHelper, urlHelper.Action("Detail", "Prayer", new { id = prayer.Id, affiliatekey = affiliate.Key })); model.ManageUrl = controller.controllerHelper.Absolute(urlHelper, urlHelper.Action("Index", "Manage", new { affiliatekey = affiliate.Key })); - var body = ControllerHelper.RenderViewToString(controller.ControllerContext, "~/Views/Email/NoteSent.cshtml", model); - SendEmailMessage(model.To, model.Subject, body); + SendEmailMessage(prayer.AnonymousEmail, model.Subject, body); } public static void NotifyPrayerFlagged(UrlHelper urlHelper, Affiliate affiliate, Prayer prayer, PrayerFlag flag) @@ -327,22 +292,16 @@ namespace Amen.Controllers { var controller = GetBaseController(affiliate); controller.ViewBag.LogoUrl = controller.controllerHelper.Absolute(urlHelper, urlHelper.Content("~/Content/Images/amen-logo-flyin.gif")); - - var model = new AdminEmailViewModel(); - model.NotificationTypeMessage = "Prayer Flagged"; - model.PrayerTitle = prayer.Summary; - if (!string.IsNullOrEmpty(flag.Reason)) - { - model.PrayerContent = "Has been flagged for the following reason: " + flag.Reason; - } - model.Subject = "An Amen Prayer Has Been Flagged"; - model.To = affiliate.EmailFlag; - model.DetailUrl = controller.controllerHelper.Absolute(urlHelper, urlHelper.Action("Detail", "Prayer", new { id = prayer.Id, affiliatekey = affiliate.Key })); - model.ManageUrl = controller.controllerHelper.Absolute(urlHelper, urlHelper.Action("Index", "Group", new { affiliatekey = affiliate.Key })); - - var body = ControllerHelper.RenderViewToString(controller.ControllerContext, "~/Views/Email/AdminNotification.cshtml", model); - - SendEmailMessage(model.To, model.Subject, body); + var adminModel = new AdminEmailViewModel(); + adminModel.NotificationTypeMessage = "Prayer Flagged"; + adminModel.PrayerTitle = prayer.Summary; + if (!string.IsNullOrEmpty(flag.Reason)) { adminModel.PrayerContent = "Has been flagged for the following reason: " + flag.Reason; } + adminModel.Subject = "An Amen Prayer Has Been Flagged"; + adminModel.To = affiliate.EmailFlag; + adminModel.DetailUrl = controller.controllerHelper.Absolute(urlHelper, urlHelper.Action("Detail", "Prayer", new { id = prayer.Id, affiliatekey = affiliate.Key })); + adminModel.ManageUrl = controller.controllerHelper.Absolute(urlHelper, urlHelper.Action("Index", "Group", new { affiliatekey = affiliate.Key })); + var body = ControllerHelper.RenderViewToString(controller.ControllerContext, "~/Views/Email/AdminNotification.cshtml", adminModel); + SendEmailMessage(adminModel.To, adminModel.Subject, body); } } } diff --git a/Amen/Scripts/site-prayer.js b/Amen/Scripts/site-prayer.js index e4b9a10..59b0a63 100644 --- a/Amen/Scripts/site-prayer.js +++ b/Amen/Scripts/site-prayer.js @@ -600,49 +600,49 @@ $(function () { } if (name.length == 0) { - alert('First Name is required'); + alert('First Name is required.'); return false; } if (content.length == 0) { - alert('Prayer Request is required'); + alert('Prayer Request is required.'); return false; } if (email.length == 0) { - alert('Email is required'); + alert('Email is required.'); return false; } if (contactpreference == 'phone' || contactpreference == 'any') { if (phone.length == 0) { - alert('Phone is required'); + alert('Phone number is required for text notifications.'); return false; } } if (email && email.length > 0) { if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))) { - alert("You have entered an invalid email address!"); + alert("You have entered an invalid email address. Please, check and try again."); return (false); } } if (phone && phone.length > 0) { if (!(/\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/.test(phone))) { - alert("You have entered an invalid phone number!"); + alert("You have entered an invalid phone number. Please, check and try again."); return (false); } } if (UpperCasePercent(content) > 0.5) { - alert('Please do not use ALL CAPS') + alert('Please do not use ALL CAPS.') return false; } var containsLinkRegex = new RegExp(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi); if (content.match(containsLinkRegex)) { - alert('Please do not include links') + alert('Please do not include links.') return false; } diff --git a/Amen/Views/Email/AdminNotification.cshtml b/Amen/Views/Email/AdminNotification.cshtml index e90b04b..6524e1e 100644 --- a/Amen/Views/Email/AdminNotification.cshtml +++ b/Amen/Views/Email/AdminNotification.cshtml @@ -8,36 +8,63 @@ @Model.Subject + - -
- - -
- - @Model.NotificationTypeMessage + +
+
+

@Model.NotificationTypeMessage

@Model.PrayerTitle

@Model.PrayerContent

-
  • You can turn on/off notifications here.
  • Details can be found here.
-

- May God bless you, -
- -

+

May God bless you,

+ +
-
- diff --git a/Amen/Views/Email/NoteSent.cshtml b/Amen/Views/Email/NoteSent.cshtml index 24ac3e4..7f1e7cb 100644 --- a/Amen/Views/Email/NoteSent.cshtml +++ b/Amen/Views/Email/NoteSent.cshtml @@ -8,48 +8,63 @@ @Model.Subject + - -
+ +
+
+

You've received a note from someone who is praying for you.

- -
+

@Model.NoteText

-

- - You've received a note from someone who is praying for you. - -

+

This was in response to this prayer you posted:

-

- @Model.NoteText -

+

@Model.Title

-

- This was in response to this prayer you posted: -

+

We hope you are encouraged by knowing that others are lifting you up in prayer.

-

- @Model.Title -

+ -

- We hope you are encouraged by knowing that others are lifting you up in prayer. -

+ -

- When it's appropriate, we'd love to hear how God is answering this request.
Share your story here. -

+

May God bless you,

-

- You can turn on/off notifications for this prayer here. -

- -

- May God bless you, -

- +
diff --git a/Amen/Views/Email/Prayed.cshtml b/Amen/Views/Email/Prayed.cshtml index e52be2e..bb4eea3 100644 --- a/Amen/Views/Email/Prayed.cshtml +++ b/Amen/Views/Email/Prayed.cshtml @@ -8,43 +8,61 @@ @Model.Subject + - + +
+
+

Someone just prayed for you!

-
+

You're being prayed for! Someone just prayed for the following prayer you posted:

-
- -

- - Someone just prayed for you! - -

- -

- You're being prayed for! Someone just prayed for the following prayer you posted: -

- -

- @Model.Title -

+

@Model.Title

We hope you are encouraged by knowing that others are lifting you up in prayer.

-

- When it's appropriate, we'd love to hear how God is answering this request.
Share your story here. -

+ -

- You can turn on/off notifications for this prayer here. -

+ -

- May God bless you, -

- +

May God bless you,

+
diff --git a/Amen/Views/Email/PrayerSubmitted.cshtml b/Amen/Views/Email/PrayerSubmitted.cshtml index eb04a37..0ef1250 100644 --- a/Amen/Views/Email/PrayerSubmitted.cshtml +++ b/Amen/Views/Email/PrayerSubmitted.cshtml @@ -8,32 +8,64 @@ @Model.Subject - - + + + + +
+
+

Thanks for posting your prayer request.

+ +

God knows your heart and your needs, and He hears you!

+ +

Let others know you need prayer. You can share this request via email or your favorite social media platform.

@if (Model.IsUserLoggedIn) { -
    -
  • You can turn on/off notifications of prayers being prayed here.
  • -
  • Should you want to edit or delete your request, you can do that here.
  • -
+
    +
  • You can turn on/off notifications of prayers being prayed here.
  • +
  • Should you want to edit or delete your request, you can do that here.
  • +
} -

- May God bless you, -
- -

+

May God bless you,

+ +
-
- \ No newline at end of file diff --git a/Amen/Views/Prayer/_PrayerItems.cshtml b/Amen/Views/Prayer/_PrayerItems.cshtml index 2dd4ad0..bd7497f 100644 --- a/Amen/Views/Prayer/_PrayerItems.cshtml +++ b/Amen/Views/Prayer/_PrayerItems.cshtml @@ -14,14 +14,14 @@ @if (prayer.HasUserName || prayer.HasUserLocation) { } @*@prayer.Summary - title used to be displayed and linked to individual prayer, now it's the name above'*@ @@ -31,62 +31,53 @@ @{WriteLiteral(Server.HtmlEncode(prayer.Content).Replace("\r\n", "\r").Replace("\r", "
").Replace("\n", "
"));}
- @if (ViewBag.HideAction != true) + @if (ViewBag.HideAction != true) { - if (prayer.IsPraise) { -
- +
} else { + + @prayer.CountPrayed + prayers + - + -
- - @prayer.CountPrayed - prayers - + }