public ActionResult UpdateDeliveryDetails(SaveCartViewModel model)
        {
            string           userId      = User.Identity.GetUserId();
            ShoppingCart     sessionCart = GetCartFromSession(userId);
            FreeMarketObject result;

            TimeSpan startTime = new TimeSpan(8, 0, 0);
            TimeSpan endTime   = new TimeSpan(17, 0, 0);

            if (model.DeliveryOptions == null || model.DeliveryOptions.SelectedDeliveryType == null)
            {
                ModelState.AddModelError("", "Please select a delivery option");
            }

            if (ModelState.IsValid)
            {
                if (!(model.prefDeliveryDateTime.Value.TimeOfDay > startTime &&
                      model.prefDeliveryDateTime.Value.TimeOfDay < endTime &&
                      model.prefDeliveryDateTime.Value > DateTime.Today &&
                      (model.prefDeliveryDateTime.Value.DayOfWeek == DayOfWeek.Monday ||
                       model.prefDeliveryDateTime.Value.DayOfWeek == DayOfWeek.Tuesday ||
                       model.prefDeliveryDateTime.Value.DayOfWeek == DayOfWeek.Wednesday ||
                       model.prefDeliveryDateTime.Value.DayOfWeek == DayOfWeek.Thursday ||
                       model.prefDeliveryDateTime.Value.DayOfWeek == DayOfWeek.Friday)))
                {
                    model.SetAddressNameOptions(userId, model.SelectedAddress);

                    return(View("CheckoutDeliveryDetails", model));
                }

                sessionCart.UpdateDeliveryDetails(model);
                result = new FreeMarketObject {
                    Result = FreeMarketResult.NoResult
                };
                if (model.AddressName != "Current")
                {
                    result = CustomerAddress.AddOrUpdateAddress(model, userId);
                }

                AuditUser.LogAudit(27, string.Format("Order Number: {0}", sessionCart.Order.OrderNumber), User.Identity.GetUserId());

                if (result.Result == FreeMarketResult.Success)
                {
                    TempData["message"] = result.Message;
                }
                else
                {
                    TempData["errorMessage"] = result.Message;
                }

                if (Request.IsAjaxRequest())
                {
                    return(JavaScript("window.location.reload();"));
                }
                else
                {
                    return(RedirectToAction("ChoosePaymentOption", "ShoppingCart"));
                }
            }

            model.SetAddressNameOptions(userId, model.SelectedAddress);

            decimal localCourierCost = sessionCart.CalculateLocalCourierFeeAdhoc(int.Parse(model.Address.AddressPostalCode));
            decimal courierCost      = sessionCart.CalculateCourierFeeAdhoc(int.Parse(model.Address.AddressPostalCode));
            decimal postOfficeCost   = sessionCart.CalculatePostalFee();

            model.SetDeliveryOptions(sessionCart.Order, /*localCourierCost,*/ courierCost, postOfficeCost);
            model.SetTextBlocks();

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_SaveCartModal", model));
            }
            else
            {
                return(View("CheckoutDeliveryDetails", model));
            }
        }