示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CheckoutPaymentManagerBase"/> class.
 /// </summary>
 /// <param name="context">
 /// The context.
 /// </param>
 /// <param name="invoiceBuilder">
 /// A lazy instantiate to get an invoice BuilderChain.
 /// </param>
 protected CheckoutPaymentManagerBase(ICheckoutContext context, IBuilderChain <IInvoice> invoiceBuilder)
     : base(context)
 {
     Mandate.ParameterNotNull(invoiceBuilder, "invoiceBuilder");
     this._invoiceBuilder = invoiceBuilder;
     this.Initialize();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CheckoutPaymentManagerBase"/> class.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <param name="invoiceBuilder">
        /// A lazy instantiate to get an invoice BuilderChain.
        /// </param>
        protected CheckoutPaymentManagerBase(ICheckoutContext context, IBuilderChain<IInvoice> invoiceBuilder)
            : base(context)
        {
            Mandate.ParameterNotNull(invoiceBuilder, "invoiceBuilder");
            this._invoiceBuilder = invoiceBuilder;

            this.Initialize();
        }
示例#3
0
        /// <summary>
        /// Generates an <see cref="IInvoice"/> representing the bill for the current "checkout order"
        /// </summary>
        /// <param name="invoiceBuilder">The invoice builder class</param>
        /// <returns>An <see cref="IInvoice"/> that is not persisted to the database.</returns>
        public IInvoice PrepareInvoice(IBuilderChain <IInvoice> invoiceBuilder)
        {
            if (!IsReadyToInvoice())
            {
                return(null);
            }

            var attempt = invoiceBuilder.Build();

            if (!attempt.Success)
            {
                LogHelper.Error <SalePreparationBase>("The invoice builder failed to generate an invoice.", attempt.Exception);
                throw attempt.Exception;
            }

            return(attempt.Result);
        }
示例#4
0
        /// <summary>
        /// Prepares an <see cref="IOrder"/> without saving it to the database.
        /// </summary>
        /// <param name="invoice">The <see cref="IInvoice"/> to base the order on</param>
        /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param>
        /// <param name="orderBuilder">The <see cref="IBuilderChain{IOrder}"/></param>
        /// <returns>The <see cref="IOrder"/></returns>
        /// <remarks>
        ///
        /// This method will save the invoice in the event it has not previously been saved
        ///
        /// </remarks>
        public static IOrder PrepareOrder(this IInvoice invoice, IMerchelloContext merchelloContext,
                                          IBuilderChain <IOrder> orderBuilder)
        {
            if (!invoice.HasIdentity)
            {
                merchelloContext.Services.InvoiceService.Save(invoice);
            }

            var attempt = orderBuilder.Build();

            if (attempt.Success)
            {
                return(attempt.Result);
            }

            LogHelper.Error <OrderBuilderChain>("Extension method PrepareOrder failed", attempt.Exception);
            throw attempt.Exception;
        }
        /// <summary>
        /// Generates an <see cref="IInvoice"/> representing the bill for the current "checkout order"
        /// </summary>
        /// <param name="invoiceBuilder">The invoice builder class</param>
        /// <returns>An <see cref="IInvoice"/> that is not persisted to the database.</returns>
        public IInvoice PrepareInvoice(IBuilderChain <IInvoice> invoiceBuilder)
        {
            if (!IsReadyToInvoice())
            {
                return(null);
            }

            var attempt = invoiceBuilder.Build();

            if (attempt.Success)
            {
                InvoicePrepared.RaiseEvent(new SalesPreparationEventArgs <IInvoice>(attempt.Result), this);

                return(attempt.Result);
            }

            LogHelper.Error <SalePreparationBase>("The invoice builder failed to generate an invoice.", attempt.Exception);

            throw attempt.Exception;
        }
        /// <summary>
        /// Generates an <see cref="IInvoice"/> representing the bill for the current "checkout order"
        /// </summary>
        /// <param name="invoiceBuilder">The invoice builder class</param>
        /// <returns>An <see cref="IInvoice"/> that is not persisted to the database.</returns>
        public virtual IInvoice PrepareInvoice(IBuilderChain <IInvoice> invoiceBuilder)
        {
            if (!IsReadyToInvoice())
            {
                return(null);
            }

            ////var requestCache = _merchelloContext.Cache.RequestCache;
            ////var cacheKey = string.Format("merchello.salespreparationbase.prepareinvoice.{0}", ItemCache.VersionKey);
            var attempt = invoiceBuilder.Build();

            if (attempt.Success)
            {
                InvoicePrepared.RaiseEvent(new CheckoutEventArgs <IInvoice>(Context.Customer, attempt.Result), this);

                return(attempt.Result);
            }

            LogHelper.Error <SalePreparationBase>("The invoice builder failed to generate an invoice.", attempt.Exception);

            throw attempt.Exception;
        }
示例#7
0
        /// <summary>
        /// Generates an <see cref="IInvoice"/> representing the bill for the current "checkout order"
        /// </summary>
        /// <param name="invoiceBuilder">The invoice builder class</param>
        /// <returns>An <see cref="IInvoice"/> that is not persisted to the database.</returns>
        public IInvoice PrepareInvoice(IBuilderChain<IInvoice> invoiceBuilder)
        {
            if (!IsReadyToInvoice()) return null;

            var attempt = invoiceBuilder.Build();

            if (attempt.Success) return attempt.Result;

            LogHelper.Error<SalePreparationBase>("The invoice builder failed to generate an invoice.", attempt.Exception);

            throw attempt.Exception;
        }
示例#8
0
        /// <summary>
        /// Prepares an <see cref="IOrder"/> without saving it to the database.  
        /// </summary>
        /// <param name="invoice">The <see cref="IInvoice"/> to base the order on</param>
        /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param>
        /// <param name="orderBuilder">The <see cref="IBuilderChain{IOrder}"/></param>
        /// <returns>The <see cref="IOrder"/></returns>
        /// <remarks>
        /// 
        /// This method will save the invoice in the event it has not previously been saved
        /// 
        /// </remarks>
        public static IOrder PrepareOrder(
            this IInvoice invoice,
            IMerchelloContext merchelloContext,
            IBuilderChain<IOrder> orderBuilder)
        {
            if (!invoice.HasIdentity) merchelloContext.Services.InvoiceService.Save(invoice);

            var attempt = orderBuilder.Build();
            if (attempt.Success) return attempt.Result;

            LogHelper.Error<OrderBuilderChain>("Extension method PrepareOrder failed", attempt.Exception);
            throw attempt.Exception;
        }
示例#9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BasketCheckoutPaymentManager"/> class.
 /// </summary>
 /// <param name="context">
 /// The context.
 /// </param>
 /// <param name="invoiceBuilder">
 ///  A lazy BuilderChain.
 /// </param>
 public BasketCheckoutPaymentManager(ICheckoutContext context, IBuilderChain <IInvoice> invoiceBuilder)
     : base(context, invoiceBuilder)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BasketCheckoutPaymentManager"/> class.
 /// </summary>
 /// <param name="context">
 /// The context.
 /// </param>
 /// <param name="invoiceBuilder">
 ///  A lazy BuilderChain.
 /// </param>
 public BasketCheckoutPaymentManager(ICheckoutContext context, IBuilderChain<IInvoice> invoiceBuilder)
     : base(context, invoiceBuilder)
 {
 }
        /// <summary>
        /// Generates an <see cref="IInvoice"/> representing the bill for the current "checkout order"
        /// </summary>
        /// <param name="invoiceBuilder">The invoice builder class</param>
        /// <returns>An <see cref="IInvoice"/> that is not persisted to the database.</returns>
        public virtual IInvoice PrepareInvoice(IBuilderChain<IInvoice> invoiceBuilder)
        {
            if (!IsReadyToInvoice()) return null;

            ////var requestCache = _merchelloContext.Cache.RequestCache;
            ////var cacheKey = string.Format("merchello.salespreparationbase.prepareinvoice.{0}", ItemCache.VersionKey);
            var attempt = invoiceBuilder.Build();

            if (attempt.Success)
            {
                InvoicePrepared.RaiseEvent(new CheckoutEventArgs<IInvoice>(Context.Customer, attempt.Result), this);

                return attempt.Result;
            }

            LogHelper.Error<SalePreparationBase>("The invoice builder failed to generate an invoice.", attempt.Exception);

            throw attempt.Exception;
        }