Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Offer"/> class for specified customer.
        /// </summary>
        /// <param name="draft">Source draft for the offer.</param>
        /// <param name="expiresOn"><see cref="DateTime"/> after which the offer is no longer valid.</param>
        public Offer(OfferDraft draft, DateTime expiresOn)
        {
            if (draft == null)
            {
                throw new ArgumentNullException("draft");
            }
            if (draft.Owner == null)
            {
                throw new ArgumentException("Owner for the offer is not specified.", "draft");
            }
            if (draft.Customer == null)
            {
                throw new ArgumentException("Customer for the offer is not specified.", "draft");
            }
            if (expiresOn < DateTime.Now)
            {
                throw new ArgumentOutOfRangeException("expiresOn", expiresOn, "Offer expiry date should be in the future.");
            }

            _owner          = draft.Owner;
            _customer       = draft.Customer;
            _title          = draft.Title;
            _discount       = draft.Discount;
            _expiresOn      = expiresOn;
            _offeredOn      = DateTime.Now;
            _discountAmount = draft.DiscountAmount;
            _subtotal       = draft.Subtotal;
            _total          = draft.Total;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new draft from given offer.
        /// </summary>
        /// <returns>A new <see cref="OfferDraft"/> instance.</returns>
        public static OfferDraft CreateFromOffer(Offer sourceOffer)
        {
            if (sourceOffer == null)
            {
                throw new ArgumentNullException("sourceOffer");
            }

            var draft = new OfferDraft(sourceOffer);

            foreach (var item in sourceOffer.Items)
            {
                var draftItem = new OfferDraftItem(item.Product, item.Quantity);
                draft.AddItem(draftItem);
                draft.ChangeItemDiscount(draftItem, item.Discount);
            }

            return(draft);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Offer"/> class for specified customer.
        /// </summary>
        /// <param name="draft">Source draft for the offer.</param>
        /// <param name="expiresOn"><see cref="DateTime"/> after which the offer is no longer valid.</param>
        public Offer(OfferDraft draft, DateTime expiresOn)
        {
            if (draft == null)
                throw new ArgumentNullException("draft");
            if (draft.Owner == null)
                throw new ArgumentException("Owner for the offer is not specified.", "draft");
            if (draft.Customer == null)
                throw new ArgumentException("Customer for the offer is not specified.", "draft");
            if (expiresOn < DateTime.Now)
                throw new ArgumentOutOfRangeException("expiresOn", expiresOn, "Offer expiry date should be in the future.");

            _owner = draft.Owner;
            _customer = draft.Customer;
            _title = draft.Title;
            _discount = draft.Discount;
            _expiresOn = expiresOn;
            _offeredOn = DateTime.Now;
            _discountAmount = draft.DiscountAmount;
            _subtotal = draft.Subtotal;
            _total = draft.Total;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new draft from given offer.
        /// </summary>
        /// <returns>A new <see cref="OfferDraft"/> instance.</returns>
        public static OfferDraft CreateFromOffer(Offer sourceOffer)
        {
            if (sourceOffer == null)
                throw new ArgumentNullException("sourceOffer");

            var draft = new OfferDraft(sourceOffer);
            foreach (var item in sourceOffer.Items)
            {
                var draftItem = new OfferDraftItem(item.Product, item.Quantity);
                draft.AddItem(draftItem);
                draft.ChangeItemDiscount(draftItem, item.Discount);
            }

            return draft;
        }