nopSolutions/nopCommerce · warning · Exception

Enter delivery date

Error message

Enter delivery date

What it means

Thrown in the OrderController shipment 'delivered' action when model.DeliveryDateUtc is null. The action demands an explicit delivery date before updating the shipment. Base Exception, caught, surfaced via ErrorNotificationAsync, redirect to shipment details.

Source

Thrown at src/Presentation/Nop.Web/Areas/Admin/Controllers/OrderController.cs:2342

    [HttpPost, ActionName("ShipmentDetails")]
    [FormValueRequired("savedeliverydate")]
    [CheckPermission(StandardPermission.Orders.SHIPMENTS_CREATE_EDIT_DELETE)]
    public virtual async Task<IActionResult> EditDeliveryDate(ShipmentModel model)
    {
        //try to get a shipment with the specified id
        var shipment = await _shipmentService.GetShipmentByIdAsync(model.Id);
        if (shipment == null)
            return RedirectToAction("List");

        //a vendor should have access only to his products
        if (await _workContext.GetCurrentVendorAsync() != null && !await HasAccessToShipmentAsync(shipment))
            return RedirectToAction("List");

        try
        {
            if (!model.DeliveryDateUtc.HasValue)
                throw new Exception("Enter delivery date");

            shipment.DeliveryDateUtc = model.DeliveryDateUtc;
            await _shipmentService.UpdateShipmentAsync(shipment);
            return RedirectToAction("ShipmentDetails", new { id = shipment.Id });
        }
        catch (Exception exc)
        {
            //error
            await _notificationService.ErrorNotificationAsync(exc);
            return RedirectToAction("ShipmentDetails", new { id = shipment.Id });
        }
    }

    [CheckPermission(StandardPermission.Orders.SHIPMENTS_VIEW)]
    public virtual async Task<IActionResult> PdfPackagingSlip(int shipmentId)
    {
        //try to get a shipment with the specified id
        var shipment = await _shipmentService.GetShipmentByIdAsync(shipmentId);

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Select a delivery date before submitting the form.
  2. Ensure DeliveryDateUtc is included and parses correctly in the POST.
  3. Enforce a client-side required validator on the delivery date.
  4. If appropriate, default DeliveryDateUtc to DateTime.UtcNow when not provided.

Example fix

// before
if (!model.DeliveryDateUtc.HasValue)
    throw new Exception("Enter delivery date");
shipment.DeliveryDateUtc = model.DeliveryDateUtc;

// after — default to now when omitted
shipment.DeliveryDateUtc = model.DeliveryDateUtc ?? DateTime.UtcNow;
await _shipmentService.UpdateShipmentAsync(shipment);
Defensive patterns

Strategy: validation

Validate before calling

// Before marking delivered: ensure a date, defaulting to now
if (!model.DeliveryDateUtc.HasValue)
    model.DeliveryDateUtc = DateTime.UtcNow;
shipment.DeliveryDateUtc = model.DeliveryDateUtc;

Type guard

bool HasDeliveryDate(ShipmentModel m) => m.DeliveryDateUtc.HasValue;

Try / catch

// The action's try/catch shows the exception via ErrorNotificationAsync; require the date client-side.

Prevention

When it happens

Trigger: POST to mark a shipment delivered with DeliveryDateUtc missing or null from the request.

Common situations: Delivery date picker left empty; the field removed in a custom view; integration/API call omitting the date; locale format causing the picker to post empty.

Related errors


AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13). Data as JSON: /api/errors/819bcc521e8770b2. Report an issue: GitHub.