Skip to content

Commit

Permalink
Added the ability to suppress the sending of confirmation emails for …
Browse files Browse the repository at this point in the history
…quotes and orders in support of #373.
  • Loading branch information
uncheckederror committed Aug 2, 2023
1 parent ee167d4 commit 803f33f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions NumberSearch.DataAccess/Models/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class Order
public string BillingInvoiceId { get; set; } = string.Empty;
public decimal SalesTax { get; set; }
public bool Quote { get; set; }
public bool NoEmail { get; set; }
public string BillingInvoiceReoccuringId { get; set; } = string.Empty;
public string SalesEmail { get; set; } = string.Empty;
public bool BackgroundWorkCompleted { get; set; }
Expand Down
13 changes: 8 additions & 5 deletions NumberSearch.Mvc/Controllers/CartController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,9 @@ public async Task<IActionResult> SubmitAsync(Order order)
// Send a confirmation email.
if (submittedOrder)
{
bool NoEmail = order.NoEmail;
order = await Order.GetByIdAsync(order.OrderId, _postgresql).ConfigureAwait(false);
order.NoEmail = NoEmail;

// Submit the number orders and track the total cost.
var onetimeItems = new List<Line_Items>();
Expand Down Expand Up @@ -1427,19 +1429,20 @@ Accelerate Networks
confirmationEmail.CalendarInvite = icalString;
}

// If there are notes on the order don't send out any emails to the customer.
if (string.IsNullOrWhiteSpace(order.CustomerNotes))
// Suppress the confirmation emails.
if (order.NoEmail)
{
// Queue up the confirmation email.
confirmationEmail.Completed = false;
confirmationEmail.PrimaryEmailAddress = string.IsNullOrWhiteSpace(order.SalesEmail) ? "[email protected]" : order.SalesEmail;
var checkSave = await confirmationEmail.PostAsync(_postgresql).ConfigureAwait(false);
Log.Information($"Suppressed sending out the confirmation emails for {order.OrderId}.");
}
else
{
// Queue up the confirmation email.
confirmationEmail.Completed = false;
confirmationEmail.PrimaryEmailAddress = string.IsNullOrWhiteSpace(order.SalesEmail) ? "[email protected]" : order.SalesEmail;
var checkSave = await confirmationEmail.PostAsync(_postgresql).ConfigureAwait(false);
Log.Information($"Skipped sending out the confirmation emails for {order.OrderId} due to customer notes.");
Log.Information($"Sent out the confirmation emails for {order.OrderId}.");
}

// Allow the background work to commence.
Expand Down
2 changes: 0 additions & 2 deletions NumberSearch.Mvc/Controllers/LookupController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
using System.Text;
using System.Threading.Tasks;

using static Microsoft.ApplicationInsights.MetricDimensionNames.TelemetryContext;

namespace NumberSearch.Mvc.Controllers
{
[ApiExplorerSettings(IgnoreApi = true)]
Expand Down
8 changes: 8 additions & 0 deletions NumberSearch.Mvc/Views/Cart/Order.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,14 @@
<label for="customernotes">Notes <span class="text-muted">(Optional)</span></label>
<input asp-for="Order!.CustomerNotes" type="text" class="form-control" id="customernotes" placeholder="Add important information for our staff">
</div>
<div class="col-md-12">
<div class="form-check">
<input asp-for="Order!.NoEmail" type="checkbox" class="form-check-input" id="defaultCheck1">
<label class="form-check-label" for="defaultCheck1">
Do not send a confirmation email
</label>
</div>
</div>
<div class="col-md-12">
<div class="form-check">
<input asp-for="Order!.Quote" type="checkbox" class="form-check-input" id="defaultCheck1">
Expand Down

0 comments on commit 803f33f

Please sign in to comment.