/// <summary> /// Renders a sales receipt. /// </summary> /// <param name="view"> /// The optional view. /// </param> /// <returns> /// The <see cref="ActionResult"/>. /// </returns> /// <exception cref="NullReferenceException"> /// Throws a null reference exception if the "invoiceKey" is not stored in the CustomerContext /// </exception> public virtual ActionResult SalesReceipt(string view = "") { var logData = MultiLogger.GetBaseLoggingData(); logData.AddCategory("Controllers"); var invoiceKey = CustomerContext.GetValue("invoiceKey"); if (invoiceKey.IsNullOrWhiteSpace()) { var nullRef = new NullReferenceException("The parameter invoiceKey was not found in the CustomerContext"); MultiLogHelper.Error <CheckoutSummaryControllerBase <TSummary, TBillingAddress, TShippingAddress, TLineItem> >("The 'invoiceKey' parameter was not found in the CustomerContext", nullRef, logData); throw nullRef; } try { var key = new Guid(invoiceKey); var invoice = MerchelloServices.InvoiceService.GetByKey(key); var model = CheckoutSummaryFactory.Create(invoice); return(view.IsNullOrWhiteSpace() ? this.PartialView(model) : this.PartialView(view, model)); } catch (Exception ex) { MultiLogHelper.Error <CheckoutSummaryControllerBase <TSummary, TBillingAddress, TShippingAddress, TLineItem> >("Could not render the receipt.", ex, logData); throw; } }
public override ActionResult PaymentForm(string view = "") { var paymentMethod = this.CheckoutManager.Payment.GetPaymentMethod(); if (paymentMethod == null) { return(this.InvalidCheckoutStagePartial()); } var model = this.CheckoutPaymentModelFactory.Create(CurrentCustomer, paymentMethod); if (!string.IsNullOrEmpty(CustomerContext.GetValue("errorMessage"))) { model.ErrorMessage = CustomerContext.GetValue("errorMessage"); CustomerContext.SetValue("errorMessage", ""); } return(view.IsNullOrWhiteSpace() ? this.PartialView(model) : this.PartialView(view, model)); }
/// <summary> /// The index <see cref="ActionResult"/>. /// </summary> /// <param name="model"> /// The current render model. /// </param> /// <returns> /// The <see cref="ActionResult"/>. /// </returns> public override ActionResult Index(RenderModel model) { var key = CustomerContext.GetValue("invoiceKey"); if (string.IsNullOrEmpty(key)) { var nullReference = new NullReferenceException("Invoice key was not found in the customer context"); LogHelper.Error <BazaarReceiptController>("Could not find a reference to the invoice key", nullReference); var store = model.Content.Ancestor("BazaarStore"); return(Redirect(store.Url)); } var invoiceKey = new Guid(key); var invoice = MerchelloServices.InvoiceService.GetByKey(invoiceKey); var viewModel = ViewModelFactory.CreateReceipt(model, invoice); return(this.View(viewModel.ThemeViewPath("Receipt"), viewModel)); }
/// <summary> /// deserialize recently viewed. /// </summary> private void Initialize() { var value = CustomerContext.GetValue("costage"); _stage = value.IsNullOrWhiteSpace() ? 0 : int.Parse(value); }
/// <summary> /// Initializes the context. /// </summary> private void Initialize() { var value = CustomerContext.GetValue("ikey"); _invoiceKey = value.IsNullOrWhiteSpace() ? Guid.Empty : new Guid(value); }