示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Shipment"/> class.
        /// </summary>
        /// <param name="shipmentStatus">
        /// The shipment Status.
        /// </param>
        /// <param name="origin">
        /// The origin.
        /// </param>
        /// <param name="destination">
        /// The destination.
        /// </param>
        /// <param name="items">
        /// The items.
        /// </param>
        internal Shipment(IShipmentStatus shipmentStatus, IAddress origin, IAddress destination, LineItemCollection items)
        {
            Mandate.ParameterNotNull(shipmentStatus, "shipmentStatus");
            Mandate.ParameterNotNull(origin, "origin");
            Mandate.ParameterNotNull(destination, "destination");
            Mandate.ParameterNotNull(items, "items");

            _shippedDate      = DateTime.Now;
            _fromOrganization = origin.Organization;
            _fromName         = origin.Name;
            _fromAddress1     = origin.Address1;
            _fromAddress2     = origin.Address2;
            _fromLocality     = origin.Locality;
            _fromRegion       = origin.Region;
            _fromPostalCode   = origin.PostalCode;
            _fromCountryCode  = origin.CountryCode;
            _fromIsCommercial = origin.IsCommercial;
            _toOrganization   = destination.Organization;
            _toName           = destination.Name;
            _toAddress1       = destination.Address1;
            _toAddress2       = destination.Address2;
            _toLocality       = destination.Locality;
            _toRegion         = destination.Region;
            _toPostalCode     = destination.PostalCode;
            _toCountryCode    = destination.CountryCode;
            _toIsCommercial   = destination.IsCommercial;

            _phone = destination.Phone;
            _email = destination.Email;

            _shipmentStatus = shipmentStatus;
            _items          = items;
        }
示例#2
0
        /// <summary>
        /// Creates a <see cref="IShipment"/> without persisting it to the database.
        /// </summary>
        /// <param name="shipmentStatus">
        /// The shipment status.
        /// </param>
        /// <param name="origin">
        /// The origin.
        /// </param>
        /// <param name="destination">
        /// The destination.
        /// </param>
        /// <param name="items">
        /// The items.
        /// </param>
        /// <param name="raiseEvents">
        /// Optional boolean indicating whether or not to raise events
        /// </param>
        /// <returns>
        /// The <see cref="IShipment"/>.
        /// </returns>
        public IShipment CreateShipment(IShipmentStatus shipmentStatus, IAddress origin, IAddress destination, LineItemCollection items, bool raiseEvents = true)
        {
            Mandate.ParameterNotNull(shipmentStatus, "shipmentStatus");
            Mandate.ParameterNotNull(origin, "origin");
            Mandate.ParameterNotNull(destination, "destination");
            Mandate.ParameterNotNull(items, "items");

            // Use the visitor to filter out and validate shippable line items
            var visitor = new ShippableProductVisitor();

            items.Accept(visitor);

            var lineItemCollection = new LineItemCollection();

            foreach (var item in visitor.ShippableItems)
            {
                lineItemCollection.Add(item);
            }

            var shipment = new Shipment(shipmentStatus, origin, destination, lineItemCollection)
            {
                VersionKey = Guid.NewGuid()
            };

            if (!raiseEvents)
            {
                return(shipment);
            }

            Creating.RaiseEvent(new Events.NewEventArgs <IShipment>(shipment), this);
            return(shipment);
        }
示例#3
0
 /// <summary>
 /// Creates a <see cref="IShipment"/> without persisting it to the database.
 /// </summary>
 /// <param name="shipmentStatus">
 /// The shipment status.
 /// </param>
 /// <param name="origin">
 /// The origin.
 /// </param>
 /// <param name="destination">
 /// The destination.
 /// </param>
 /// <param name="raiseEvents">
 /// Optional boolean indicating whether or not to raise events
 /// </param>
 /// <returns>
 /// The <see cref="IShipment"/>.
 /// </returns>
 public IShipment CreateShipment(IShipmentStatus shipmentStatus, IAddress origin, IAddress destination, bool raiseEvents = true)
 {
     return(CreateShipment(shipmentStatus, origin, destination, new LineItemCollection()));
 }
示例#4
0
 /// <summary>
 /// Creates a <see cref="IShipment"/> without persisting it to the database.
 /// </summary>
 /// <param name="shipmentStatus">
 /// The shipment status.
 /// </param>
 /// <param name="raiseEvents">
 /// Optional boolean indicating whether or not to raise events
 /// </param>
 /// <returns>
 /// The <see cref="IShipment"/>.
 /// </returns>
 public IShipment CreateShipment(IShipmentStatus shipmentStatus, bool raiseEvents = true)
 {
     return(CreateShipment(shipmentStatus, new Address(), new Address(), new LineItemCollection()));
 }
示例#5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Shipment"/> class.
        /// </summary>
        /// <param name="shipmentStatus">
        /// The shipment Status.
        /// </param>
        /// <param name="origin">
        /// The origin.
        /// </param>
        /// <param name="destination">
        /// The destination.
        /// </param>
        /// <param name="items">
        /// The items.
        /// </param>
        internal Shipment(IShipmentStatus shipmentStatus, IAddress origin, IAddress destination, LineItemCollection items)
        {
            Mandate.ParameterNotNull(shipmentStatus, "shipmentStatus");
            Mandate.ParameterNotNull(origin, "origin");
            Mandate.ParameterNotNull(destination, "destination");
            Mandate.ParameterNotNull(items, "items");

            _shippedDate = DateTime.Now;
            _fromOrganization = origin.Organization;
            _fromName = origin.Name;
            _fromAddress1 = origin.Address1;
            _fromAddress2 = origin.Address2;
            _fromLocality = origin.Locality;
            _fromRegion = origin.Region;
            _fromPostalCode = origin.PostalCode;
            _fromCountryCode = origin.CountryCode;
            _fromIsCommercial = origin.IsCommercial;
            _toOrganization = destination.Organization;
            _toName = destination.Name;
            _toAddress1 = destination.Address1;
            _toAddress2 = destination.Address2;
            _toLocality = destination.Locality;
            _toRegion = destination.Region;
            _toPostalCode = destination.PostalCode;
            _toCountryCode = destination.CountryCode;
            _toIsCommercial = destination.IsCommercial;

            _phone = destination.Phone;
            _email = destination.Email;

            _shipmentStatus = shipmentStatus;
            _items = items;
        }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Shipment"/> class.
 /// </summary>
 /// <param name="shipmentStatus">
 /// The shipment Status.
 /// </param>
 /// <param name="origin">
 /// The origin.
 /// </param>
 /// <param name="destination">
 /// The destination.
 /// </param>
 internal Shipment(IShipmentStatus shipmentStatus, IAddress origin, IAddress destination)
     : this(shipmentStatus, origin, destination, new LineItemCollection())
 {
 }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Shipment"/> class.
 /// </summary>
 /// <param name="shipmentStatus">
 /// The shipment Status.
 /// </param>
 internal Shipment(IShipmentStatus shipmentStatus)
     : this(shipmentStatus, new Address(), new Address(), new LineItemCollection())
 {
 }
示例#8
0
        /// <summary>
        /// Creates a <see cref="IShipment"/> without persisting it to the database.
        /// </summary>
        /// <param name="shipmentStatus">
        /// The shipment status.
        /// </param>
        /// <param name="origin">
        /// The origin.
        /// </param>
        /// <param name="destination">
        /// The destination.
        /// </param>
        /// <param name="items">
        /// The items.
        /// </param>
        /// <param name="raiseEvents">
        /// Optional boolean indicating whether or not to raise events
        /// </param>
        /// <returns>
        /// The <see cref="IShipment"/>.
        /// </returns>
        public IShipment CreateShipment(IShipmentStatus shipmentStatus, IAddress origin, IAddress destination, LineItemCollection items, bool raiseEvents = true)
        {
            Mandate.ParameterNotNull(shipmentStatus, "shipmentStatus");
            Mandate.ParameterNotNull(origin, "origin");
            Mandate.ParameterNotNull(destination, "destination");
            Mandate.ParameterNotNull(items, "items");

            // Use the visitor to filter out and validate shippable line items
            var visitor = new ShippableProductVisitor();
            items.Accept(visitor);

            var lineItemCollection = new LineItemCollection();

            foreach (var item in visitor.ShippableItems)
            {
                lineItemCollection.Add(item);
            }

            var shipment = new Shipment(shipmentStatus, origin, destination, lineItemCollection)
                               {
                                   VersionKey = Guid.NewGuid()
                               };

            if (!raiseEvents)
            {
                return shipment;
            }

            Creating.RaiseEvent(new Events.NewEventArgs<IShipment>(shipment), this);
            return shipment;
        }
示例#9
0
 /// <summary>
 /// Creates a <see cref="IShipment"/> without persisting it to the database.
 /// </summary>
 /// <param name="shipmentStatus">
 /// The shipment status.
 /// </param>
 /// <param name="origin">
 /// The origin.
 /// </param>
 /// <param name="destination">
 /// The destination.
 /// </param>
 /// <param name="raiseEvents">
 /// Optional boolean indicating whether or not to raise events
 /// </param>
 /// <returns>
 /// The <see cref="IShipment"/>.
 /// </returns>
 public IShipment CreateShipment(IShipmentStatus shipmentStatus, IAddress origin, IAddress destination, bool raiseEvents = true)
 {
     return CreateShipment(shipmentStatus, origin, destination, new LineItemCollection());
 }
示例#10
0
 /// <summary>
 /// Creates a <see cref="IShipment"/> without persisting it to the database.
 /// </summary>
 /// <param name="shipmentStatus">
 /// The shipment status.
 /// </param>
 /// <param name="raiseEvents">
 /// Optional boolean indicating whether or not to raise events
 /// </param>
 /// <returns>
 /// The <see cref="IShipment"/>.
 /// </returns>
 public IShipment CreateShipment(IShipmentStatus shipmentStatus, bool raiseEvents = true)
 {
     return CreateShipment(shipmentStatus, new Address(), new Address(), new LineItemCollection());
 }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Shipment"/> class.
 /// </summary>
 /// <param name="shipmentStatus">
 /// The shipment Status.
 /// </param>
 /// <param name="origin">
 /// The origin.
 /// </param>
 /// <param name="destination">
 /// The destination.
 /// </param>
 internal Shipment(IShipmentStatus shipmentStatus, IAddress origin, IAddress destination)
     : this(shipmentStatus, origin, destination, new LineItemCollection())
 {
 }
示例#12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Shipment"/> class.
 /// </summary>
 /// <param name="shipmentStatus">
 /// The shipment Status.
 /// </param>
 internal Shipment(IShipmentStatus shipmentStatus)
     : this(shipmentStatus, new Address(), new Address(), new LineItemCollection())
 {
 }
示例#13
0
 /// <summary>
 /// Maps a <see cref="IShipmentStatus"/> to a <see cref="ShipmentStatusDisplay"/>
 /// </summary>
 /// <param name="status">
 /// The status.
 /// </param>
 /// <returns>
 /// The <see cref="ShipmentStatusDisplay"/>.
 /// </returns>
 public static ShipmentStatusDisplay ToShipmentStatusDisplay(this IShipmentStatus status)
 {
     return(AutoMapper.Mapper.Map <ShipmentStatusDisplay>(status));
 }