Exception in template (Designs\McHutch\eCom/Order/AbandonedCart.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.afabeacaebdbc.Execute()
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
at Dynamicweb.Rendering.Template.Output()
@using System;
@using System.Collections;
@using System.Linq;
@using System.Security.Authentication;
@using McHutchison.eCommerce;
@using System.Web;
@using System;
@{
string cartId = (string)@GetValue("Ecom:Order.ID");
var cartInfo = RazorAbandonedCart.GetCartInfo(cartId);
var cartSections = cartInfo.Cart.Sections.EmptyIfNull().ToList();
var editCart = cartSections.FirstOrDefault() ?? new CartSection();
var navOrderId = editCart.OrderId;
}
<div style="font-family: Verdana, sans-serif;width: 700px;">
<p style="margin: 0 0 20px 0">
Dear @GetValue("Ecom:Order.Customer.Name"),
</p>
@{
bool isEditCart = cartInfo.IsEditCart;
string testMode = HttpContext.Current.Request["testMode"];
if (String.Equals(testMode, "new", StringComparison.OrdinalIgnoreCase)) {
isEditCart = false;
} else if (String.Equals(testMode, "edit", StringComparison.OrdinalIgnoreCase)) {
isEditCart = true;
navOrderId = "TestOrderId";
cartSections = new List<CartSection> { editCart };
}
DateTime dateTimeNow = DateTime.Now;
DateTime dateTimeNowCoerced = new DateTime(dateTimeNow.Year, dateTimeNow.Month, dateTimeNow.Day, dateTimeNow.Hour, 0, 0);
DateTime dateTimeDeletion = dateTimeNowCoerced.AddHours(3);
string dateTimeDeletionFormated = dateTimeDeletion.ToString("M/d/yyyy h:mm tt EST").Replace(" ", " ");
}
@if (isEditCart) {
<p>
You have not submitted the latest changes you made to your order no @navOrderId. If you do not submit your changes by @dateTimeDeletionFormated, the order changes will be deleted.
</p>
} else {
<p>
Please submit the orders listed below by @dateTimeDeletionFormated. If you do not submit the orders by that time, they will be deleted from the system.
</p>
}
<table style="width:700px; width:700px;font-family: Verdana, sans-serif;font-size: 14px;text-align: left;margin: 20px 0px 40px;">
<thead>
<tr style="line-height: 30px; background-color: #61af35; color: #fff">
<th style="padding-left: 5px;">Vendor</th>
<th style="padding-left: 5px;">Requested Ship Date</th>
<th style="padding-left: 5px;">Week number</th>
<th style="padding-left: 5px;">Price</th>
</tr>
</thead>
<tbody>
@foreach(var section in cartSections){
<tr>
<td>@(section.VendorName)</td>
<td>@(section.ReferenceDate.ToString("MMMM dd, yyyy"))</td>
<td>@(section.Week)</td>
<td>@(section.TotalPrice.ToCurrencyString("N/A"))</td>
</tr>
}
</tbody>
</table>
@{
int portalAreaId = 5;
var hostUrl = Dynamicweb.Content.Area.GetAreaById(portalAreaId).DomainLock;
var returnUrl = isEditCart
? String.Concat("//", hostUrl, "/edit-order?orderid=", navOrderId)
: String.Concat("//", hostUrl, "/view-cart");
var buttonWording = isEditCart
? "Return to site to finalize order changes"
: "Return to site to submit the orders";
}
<table cellpadding="10">
<tr>
<td bgcolor="#ebca4f">
<a href="@returnUrl" style="color: #000;text-decoration: none;font-weight: bold;text-transform: uppercase;inline: block;">@buttonWording</a>
</td>
</tr>
</table>
</div>
<br />
<br />
<br />
<br />
<br />