Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OfferDraft"/> class.
        /// </summary>
        /// <param name="sourceOffer">Source offer from which to create a new draft</param>
        private OfferDraft(Offer sourceOffer)
        {
            if (sourceOffer == null)
                throw new ArgumentNullException("sourceOffer");

            _sourceOffer = sourceOffer;
            _owner = sourceOffer.Owner;
            _title = sourceOffer.Title;
            _customer = sourceOffer.Customer;
            _discount = sourceOffer.Discount;
            _createdOn = DateTime.Now;
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OfferDraft"/> class.
        /// </summary>
        /// <param name="owner"><see cref="User"/> that has created the draft.</param>
        /// <param name="customer"><see cref="Customer"/> for which this offer is being created.</param>
        /// <param name="title">Title for the offer.</param>
        public OfferDraft(User owner, Customer customer, string title)
        {
            if (owner == null)
                throw new ArgumentNullException("owner");
            if (customer == null)
                throw new ArgumentNullException("customer");
            if (string.IsNullOrEmpty(title))
                throw new ArgumentNullException("title");

            _owner = owner;
            _title = title;
            _customer = customer;
            _createdOn = DateTime.Now;
        }
Пример #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;
        }