internal static IOrder ToOrder(this OrderDisplay orderDisplay, IOrder destination)
        {
            if (orderDisplay.Key != Guid.Empty)
            {
                destination.Key = orderDisplay.Key;
            }
            destination.OrderNumberPrefix = orderDisplay.OrderNumberPrefix;
            destination.OrderDate         = orderDisplay.OrderDate;
            destination.OrderStatus       = orderDisplay.OrderStatus.ToOrderStatus();
            destination.VersionKey        = orderDisplay.VersionKey;
            destination.Exported          = orderDisplay.Exported;

            // TODO remove existing line items from destination not present in orderDisplay
            var items      = destination.Items.Where(x => orderDisplay.Items.Any(display => display.Key == x.Key));
            var collection = new LineItemCollection();

            foreach (var item in items)
            {
                collection.Add(item);
            }

            ((Order)destination).Items = collection;

            return(destination);
        }
Пример #2
0
        public static LineItemCollection Select(string WhereClause, string OrderByClause)
        {
            string Sql = string.Format("SELECT * from [lineItem] WHERE ({0}) ORDER BY {1}", WhereClause, OrderByClause);
            //string ConnStr = @"Server=STUDENT05;Database=prs;Trusted_Connection=True;";
            SqlCommand    Cmd    = CreateConnection(ConnStr, Sql, "Connection didn't open");
            SqlDataReader Reader = Cmd.ExecuteReader();
            //if (!Reader.HasRows) {
            //    throw new ApplicationException("Result set has no rows!");
            //}
            LineItemCollection lineItems = new LineItemCollection();

            while (Reader.Read())
            {
                int id = Reader.GetInt32(Reader.GetOrdinal("Id"));
                int purchaseRequestId = Reader.GetInt32(Reader.GetOrdinal("PurchaseRequestId"));
                int productId         = Reader.GetInt32(Reader.GetOrdinal("ProductId"));
                int quantity          = Reader.GetInt32(Reader.GetOrdinal("Quantity"));

                LineItem lineItem = new LineItem();
                lineItem.Id = id;
                lineItem.PurchaseRequestId = purchaseRequestId;
                lineItem.ProductId         = productId;
                lineItem.Quantity          = quantity;

                // get the PurchaseRequest
                lineItem.PurchaseRequest = PurchaseRequest.Select(lineItem.PurchaseRequestId);
                // get the Product
                lineItem.Product = Product.Select(lineItem.ProductId);

                lineItems.Add(lineItem);
            }

            Cmd.Connection.Close();
            return(lineItems);
        }
Пример #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="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);
        }
Пример #4
0
        public void Init()
        {
            _address = new Address()
            {
                Name        = "Mindfly Web Design Studio",
                Address1    = "114 W. Magnolia St.  Suite 504",
                Locality    = "Bellingham",
                Region      = "WA",
                PostalCode  = "98225",
                CountryCode = "US"
            };

            var extendedData = new ExtendedDataCollection();

            extendedData.SetValue("merchProductKey", Guid.NewGuid().ToString());
            extendedData.SetValue("merchProductVariantKey", Guid.NewGuid().ToString());
            extendedData.SetValue("merchWeight", "12");

            var lineItemCollection = new LineItemCollection()
            {
                { new ItemCacheLineItem(LineItemType.Product, "Product1", "Sku1", 1, 10, extendedData) },
                { new ItemCacheLineItem(LineItemType.Product, "Product2", "Sku2", 2, 12, extendedData) },
                { new ItemCacheLineItem(LineItemType.Product, "Product3", "Sku3", 3, 14, extendedData) },
            };

            _shipment = new Shipment(_address, _address, lineItemCollection);
        }
Пример #5
0
        public ShipmentMock(IAddress origin, IAddress destination, LineItemCollection items)
        {
            this.ShippedDate      = DateTime.Now;
            this.FromOrganization = origin.Organization;
            this.FromName         = origin.Name;
            this.FromAddress1     = origin.Address1;
            this.FromAddress2     = origin.Address2;
            this.FromLocality     = origin.Locality;
            this.FromRegion       = origin.Region;
            this.FromPostalCode   = origin.PostalCode;
            this.FromCountryCode  = origin.CountryCode;
            this.FromIsCommercial = origin.IsCommercial;
            this.ToOrganization   = destination.Organization;
            this.ToName           = destination.Name;
            this.ToAddress1       = destination.Address1;
            this.ToAddress2       = destination.Address2;
            this.ToLocality       = destination.Locality;
            this.ToRegion         = destination.Region;
            this.ToPostalCode     = destination.PostalCode;
            this.ToCountryCode    = destination.CountryCode;
            this.ToIsCommercial   = destination.IsCommercial;

            this.Phone = destination.Phone;
            this.Email = destination.Email;

            this.Items = items;
        }
Пример #6
0
        /// <summary>
        /// Saves a collection of <see cref="ILineItem"/> asscoiated with a container
        /// </summary>
        /// <param name="items">The collection of <see cref="ILineItem"/></param>
        /// <param name="containerKey">The "Container" or parent collection key</param>
        public virtual void SaveLineItem(LineItemCollection items, Guid containerKey)
        {
            var existing = GetByContainerKey(containerKey);

            // assert there are no existing items not in the new set of items.  If there are ... delete them
            var toDelete = existing.Where(x => items.All(item => item.Key != x.Key)).ToArray();

            if (toDelete.Any())
            {
                foreach (var d in toDelete)
                {
                    Delete(d);
                }
            }

            foreach (var item in items)
            {
                // In the mapping between different line item types the container key is
                // invalidated so we need to set it to the current container.
                if (!item.ContainerKey.Equals(containerKey))
                {
                    item.ContainerKey = containerKey;
                }

                SaveLineItem(item as T);
            }
        }
Пример #7
0
        public static LineItem Select(int Id)
        {
            LineItemCollection lineItems = LineItem.Select($"Id = {Id}", "Id");
            LineItem           lineItem  = (lineItems.Count == 1) ? lineItems[0] : null;

            return(lineItem);
        }
 public void Write(LineItemCollection lineItems)
 {
     foreach (LineItem lineItem in lineItems)
     {
         Write(lineItem);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultWarehousePackagingStrategy"/> class.
 /// </summary>
 /// <param name="lineItemCollection">
 /// The line item collection.
 /// </param>
 /// <param name="destination">
 /// The destination.
 /// </param>
 /// <param name="versionKey">
 /// The version key.
 /// </param>
 public DefaultWarehousePackagingStrategy(
     LineItemCollection lineItemCollection,
     IAddress destination,
     Guid versionKey)
     : this(Core.MerchelloContext.Current, lineItemCollection, destination, versionKey)
 {
 }
Пример #10
0
        internal Shipment(IAddress origin, IAddress destination, LineItemCollection items)
        {
            Mandate.ParameterNotNull(origin, "origin");
            Mandate.ParameterNotNull(destination, "destination");
            Mandate.ParameterNotNull(items, "items");

            _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;

            _items = items;
        }
Пример #11
0
        public ShipmentMock(IAddress origin, IAddress destination, LineItemCollection items)
        {
            this.ShippedDate = DateTime.Now;
            this.FromOrganization = origin.Organization;
            this.FromName = origin.Name;
            this.FromAddress1 = origin.Address1;
            this.FromAddress2 = origin.Address2;
            this.FromLocality = origin.Locality;
            this.FromRegion = origin.Region;
            this.FromPostalCode = origin.PostalCode;
            this.FromCountryCode = origin.CountryCode;
            this.FromIsCommercial = origin.IsCommercial;
            this.ToOrganization = destination.Organization;
            this.ToName = destination.Name;
            this.ToAddress1 = destination.Address1;
            this.ToAddress2 = destination.Address2;
            this.ToLocality = destination.Locality;
            this.ToRegion = destination.Region;
            this.ToPostalCode = destination.PostalCode;
            this.ToCountryCode = destination.CountryCode;
            this.ToIsCommercial = destination.IsCommercial;

            this.Phone = destination.Phone;
            this.Email = destination.Email;

            this.Items = items;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultWarehousePackagingStrategy"/> class.
 /// </summary>
 /// <param name="lineItemCollection">
 /// The line item collection.
 /// </param>
 /// <param name="destination">
 /// The destination.
 /// </param>
 /// <param name="versionKey">
 /// The version key.
 /// </param>
 public DefaultWarehousePackagingStrategy(
     LineItemCollection lineItemCollection,
     IAddress destination,
     Guid versionKey)
     : base(lineItemCollection, destination, versionKey)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultWarehousePackagingStrategy"/> class.
 /// </summary>
 /// <param name="lineItemCollection">
 /// The line item collection.
 /// </param>
 /// <param name="destination">
 /// The destination.
 /// </param>
 /// <param name="versionKey">
 /// The version key.
 /// </param>
 public DefaultWarehousePackagingStrategy(
     LineItemCollection lineItemCollection,
     IAddress destination,
     Guid versionKey)
     : base(lineItemCollection, destination, versionKey)
 {
 }
Пример #14
0
        /// <summary>
        /// Loads the shipment LineItems.
        /// </summary>
        /// <param name="iStartIndex">Start index of the i.</param>
        /// <param name="iNumItems">The i num items.</param>
        /// <param name="sFilter">The s filter.</param>
        private void LoadShipmentLineItems()
        {
            string indexColumnName   = "LineItemIndex";
            string idColumnName      = "LineItemId";
            string checkedColumnName = "Checked";
            string nameColumnName    = "Name";

            DataTable lineItemsDT = new DataTable();

            lineItemsDT.Columns.AddRange(new DataColumn[4] {
                new DataColumn(indexColumnName, typeof(int)),
                new DataColumn(idColumnName, typeof(int)),
                new DataColumn(checkedColumnName, typeof(bool)),
                new DataColumn(nameColumnName, typeof(string))
            });

            // get items that are not associated with any shipment yet
            ShipmentCollection allShipments   = _order.OrderForms[0].Shipments;
            LineItemCollection orderLineItems = _order.OrderForms[0].LineItems;
            int index = -1;

            foreach (LineItem li in orderLineItems)
            {
                index++;
                bool isInShipment        = false;
                bool isInCurrentShipment = false;

                if (SelectedShipment != null && SelectedShipment.LineItemIndexes.Contains(index.ToString()))
                {
                    // if it is current shipment, add lineItem to the grid
                    isInCurrentShipment = true;
                }
                else
                {
                    foreach (Shipment shipment in allShipments)
                    {
                        if (shipment != SelectedShipment && shipment.LineItemIndexes.Contains(index.ToString()))
                        {
                            isInShipment = true;
                            break;
                        }
                    }
                }

                if (!isInShipment || isInCurrentShipment)
                {
                    // if it is current shipment, add lineItem to the grid
                    DataRow row = lineItemsDT.NewRow();
                    row[indexColumnName]   = index;
                    row[idColumnName]      = li.LineItemId;
                    row[checkedColumnName] = isInCurrentShipment;
                    row[nameColumnName]    = li.DisplayName;
                    lineItemsDT.Rows.Add(row);
                }
            }

            ShipmentItemsList.DataSource = lineItemsDT.DefaultView;
            ShipmentItemsList.DataBind();
        }
Пример #15
0
        /// <summary>
        /// Creates a collection of shipments for the current basket
        /// </summary>
        /// <returns>
        /// A collection of <see cref="IShipment"/>.
        /// </returns>
        public override IEnumerable <IShipment> PackageShipments()
        {
            // filter basket items for shippable items
            var shippableVisitor = new ShippableProductVisitor();

            LineItemCollection.Accept(shippableVisitor);

            if (!shippableVisitor.ShippableItems.Any())
            {
                return(new List <IShipment>());
            }

            // the origin address will be the default warehouse
            // For the initial version we are only exposing a single warehouse
            var warehouse = MerchelloContext.Services.WarehouseService.GetDefaultWarehouse();
            var origin    = warehouse.AsAddress();

            ////For the initial version we are only exposing a single shipment
            var shipment = new Shipment(origin, Destination)
            {
                VersionKey = VersionKey     // this is used in cache keys
            };

            // get the variants for each of the shippable line items
            var variants =
                MerchelloContext.Services.ProductVariantService.GetByKeys(
                    shippableVisitor.ShippableItems
                    .Select(x => x.ExtendedData.GetProductVariantKey())
                    .Where(x => !Guid.Empty.Equals(x))).ToArray();

            foreach (var lineItem in shippableVisitor.ShippableItems)
            {
                // We need to know what Warehouse Catalog this product is associated with for shipping and inventory
                var variant = variants.FirstOrDefault(x => x.Key.Equals(lineItem.ExtendedData.GetProductVariantKey()));
                if (variant == null)
                {
                    throw new InvalidOperationException("This packaging strategy cannot handle null ProductVariants");
                }

                if (variant.CatalogInventories.FirstOrDefault() == null)
                {
                    LogHelper.Error <ShippableProductVisitor>(
                        "ProductVariant marked as shippable was not assoicated with a WarehouseCatalog.  Product was: "
                        + variant.Key.ToString() + " -  " + variant.Name,
                        new InvalidDataException());
                }
                else
                {
                    lineItem.ExtendedData.SetValue(
                        "merchWarehouseCatalogKey",
                        variant.CatalogInventories.First().CatalogKey.ToString());
                    shipment.Items.Add(lineItem);
                }
            }

            return(new List <IShipment> {
                shipment
            });
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultWarehousePackagingStrategy"/> class.
 /// </summary>
 /// <param name="merchelloContext">
 /// The merchello context.
 /// </param>
 /// <param name="lineItemCollection">
 /// The line item collection.
 /// </param>
 /// <param name="destination">
 /// The destination.
 /// </param>
 /// <param name="versionKey">
 /// The version key.
 /// </param>
 public DefaultWarehousePackagingStrategy(
     IMerchelloContext merchelloContext,
     LineItemCollection lineItemCollection,
     IAddress destination,
     Guid versionKey)
     : base(merchelloContext, lineItemCollection, destination, versionKey)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultWarehousePackagingStrategy"/> class.
 /// </summary>
 /// <param name="merchelloContext">
 /// The merchello context.
 /// </param>
 /// <param name="lineItemCollection">
 /// The line item collection.
 /// </param>
 /// <param name="destination">
 /// The destination.
 /// </param>
 /// <param name="versionKey">
 /// The version key.
 /// </param>
 public DefaultWarehousePackagingStrategy(
     IMerchelloContext merchelloContext,
     LineItemCollection lineItemCollection,
     IAddress destination,
     Guid versionKey)
     : base(merchelloContext, lineItemCollection, destination, versionKey)
 {
 }
Пример #18
0
        public void TestQueryForListWithListClass()
        {
            LineItemCollection linesItem = dataMapper.QueryForList("GetLineItemsForOrderWithListClass", 6) as LineItemCollection;

            Assert.IsNotNull(linesItem);
            Assert.AreEqual(2, linesItem.Count);
            Assert.AreEqual("ASM-45", linesItem[0].Code);
            Assert.AreEqual("QSM-39", linesItem[1].Code);
        }
Пример #19
0
        internal ItemCache(Guid entityKey, Guid itemCacheTfKey, LineItemCollection items)
        {
            Mandate.ParameterCondition(entityKey != Guid.Empty, "entityKey");
            Mandate.ParameterCondition(itemCacheTfKey != Guid.Empty, "itemCacheTfKey");
            Mandate.ParameterNotNull(items, "items");

            _entityKey = entityKey;
            _itemCacheTfKey = itemCacheTfKey;
            _items = items;
        }
 public PurchaseRequest()
 {
     this.DateNeeded    = DateTime.Now.AddDays(7); // needed in 7 days
     this.DeliveryMode  = "USPS";                  // post office
     this.DocsAttached  = false;                   // no docs
     this.Status        = "New";                   // a new request
     this.Total         = 0.0M;                    //
     this.SubmittedDate = DateTime.Now;
     {
         LineItems = new LineItemCollection();
     }
 }
Пример #21
0
        internal PackagingStrategyBase(IMerchelloContext merchelloContext, LineItemCollection lineItemCollection, IAddress destination, Guid versionKey)
        {
            Mandate.ParameterNotNull(merchelloContext, "merchelloContext");
            Mandate.ParameterNotNull(lineItemCollection, "lineItemCollection");
            Mandate.ParameterNotNull(destination, "destination");
            Mandate.ParameterCondition(!Guid.Empty.Equals(versionKey), "versionKey");

            MerchelloContext = merchelloContext;
            LineItemCollection = lineItemCollection;
            Destination = destination;
            VersionKey = versionKey;
        }
Пример #22
0
        ///// <summary>
        ///// Initializes a new instance of the <see cref="PackagingStrategyBase"/> class.
        ///// </summary>
        ///// <param name="lineItemCollection">
        ///// The line item collection.
        ///// </param>
        ///// <param name="destination">
        ///// The destination.
        ///// </param>
        ///// <param name="versionKey">
        ///// The version key.
        ///// </param>
        //protected PackagingStrategyBase(LineItemCollection lineItemCollection, IAddress destination, Guid versionKey)
        //    : this(Core.MerchelloContext.Current, lineItemCollection, destination, versionKey)
        //{
        //}

        /// <summary>
        /// Initializes a new instance of the <see cref="PackagingStrategyBase"/> class.
        /// </summary>
        /// <param name="merchelloContext">
        /// The merchello context.
        /// </param>
        /// <param name="lineItemCollection">
        /// The line item collection.
        /// </param>
        /// <param name="destination">
        /// The destination.
        /// </param>
        /// <param name="versionKey">
        /// The version key.
        /// </param>
        protected PackagingStrategyBase(IMerchelloContext merchelloContext, LineItemCollection lineItemCollection, IAddress destination, Guid versionKey)
        {
            Ensure.ParameterNotNull(merchelloContext, "merchelloContext");
            Ensure.ParameterNotNull(lineItemCollection, "lineItemCollection");
            Ensure.ParameterNotNull(destination, "destination");
            Ensure.ParameterCondition(!Guid.Empty.Equals(versionKey), "versionKey");

            MerchelloContext   = merchelloContext;
            LineItemCollection = lineItemCollection;
            Destination        = destination;
            VersionKey         = versionKey;
        }
Пример #23
0
        internal Order(IOrderStatus orderStatus, Guid invoiceKey, LineItemCollection lineItemCollection)
        {
            Mandate.ParameterNotNull(orderStatus, "orderStatus");
            Mandate.ParameterCondition(!Guid.Empty.Equals(invoiceKey), "invoiceKey");
            Mandate.ParameterNotNull(lineItemCollection, "lineItemCollection");

            _invoiceKey = invoiceKey;
            _orderStatus = orderStatus;
            _items = lineItemCollection;

            _orderDate = DateTime.Now;
        }
Пример #24
0
        /// <summary>
        /// The get line item collection.
        /// </summary>
        /// <param name="invoiceKey">
        /// The invoice key.
        /// </param>
        /// <returns>
        /// The <see cref="LineItemCollection"/>.
        /// </returns>
        private LineItemCollection GetLineItemCollection(Guid invoiceKey)
        {
            var sql = new Sql();

            sql.Select("*").From <InvoiceItemDto>(SqlSyntax).Where <InvoiceItemDto>(x => x.ContainerKey == invoiceKey);

            var dtos = Database.Fetch <InvoiceItemDto>(sql);

            var factory    = new LineItemFactory();
            var collection = new LineItemCollection();

            foreach (var dto in dtos)
            {
                collection.Add(factory.BuildEntity(dto));
            }

            return(collection);
        }
        /// <summary>
        /// Creates an instance of <see cref="LineItemCollection"/> from a serialized collection in the ExtendedDataCollection
        /// </summary>
        /// <typeparam name="T">The type of the <see cref="ILineItem"/></typeparam>
        /// <param name="extendedData">The extended data collection</param>
        /// <returns><see cref="LineItemCollection"/></returns>
        public static LineItemCollection GetLineItemCollection <T>(this ExtendedDataCollection extendedData) where T : LineItemBase
        {
            if (!extendedData.ContainsKey(Constants.ExtendedDataKeys.LineItemCollection))
            {
                return(null);
            }

            var xdoc = XDocument.Parse(extendedData.GetValue(Constants.ExtendedDataKeys.LineItemCollection));
            var lineItemCollection = new LineItemCollection();

            foreach (var element in xdoc.Descendants(Constants.ExtendedDataKeys.LineItem))
            {
                var dictionary = GetLineItemXmlValues(element.ToString());

                var extendData = new ExtendedDataCollection(dictionary[Constants.ExtendedDataKeys.ExtendedData]);

                var ctrValues = new object[]
                {
                    new Guid(dictionary[Constants.ExtendedDataKeys.LineItemTfKey]),
                    dictionary[Constants.ExtendedDataKeys.Name],
                    dictionary[Constants.ExtendedDataKeys.Sku],
                    int.Parse(dictionary[Constants.ExtendedDataKeys.Quantity]),
                    decimal.Parse(dictionary[Constants.ExtendedDataKeys.Price], NumberStyles.Any, CultureInfo.InvariantCulture),
                    new ExtendedDataCollection(dictionary[Constants.ExtendedDataKeys.ExtendedData])
                };

                var attempt = ActivatorHelper.CreateInstance <LineItemBase>(typeof(T).FullName, ctrValues);

                if (!attempt.Success)
                {
                    MultiLogHelper.Error <LineItemCollection>("Failed to instantiate a LineItemCollection from ExtendedData", attempt.Exception);
                    throw attempt.Exception;
                }

                attempt.Result.ContainerKey = new Guid(dictionary[Constants.ExtendedDataKeys.ContainerKey]);

                lineItemCollection.Add(attempt.Result);
            }

            return(lineItemCollection);
        }
Пример #26
0
        /// <summary>
        /// Clones a shipment
        /// </summary>
        /// <param name="org">
        /// The org.
        /// </param>
        /// <returns>
        /// The <see cref="IShipment"/>.
        /// </returns>
        /// <remarks>
        /// http://issues.merchello.com/youtrack/issue/M-458
        /// </remarks>
        internal static IShipment Clone(this IShipment org)
        {
            var lineItemCollection = new LineItemCollection();

            foreach (var li in org.Items)
            {
                lineItemCollection.Add(li.AsLineItemOf <OrderLineItem>());
            }

            return(new Shipment(org.ShipmentStatus, org.GetOriginAddress(), org.GetDestinationAddress(), lineItemCollection)
            {
                ShipmentNumberPrefix = org.ShipmentNumberPrefix,
                ShipmentNumber = org.ShipmentNumber,
                ShippedDate = org.ShippedDate,
                TrackingCode = org.TrackingCode,
                Carrier = org.Carrier,
                ShipMethodKey = org.ShipMethodKey,
                Phone = org.Phone,
                Email = org.Email
            });
        }
Пример #27
0
        public void Init()
        {
            _origin = new Address()
            {
                Name         = "Mindfly Web Design Studio",
                Address1     = "114 W. Magnolia St.  Suite 504",
                Locality     = "Bellingham",
                Region       = "WA",
                PostalCode   = "98225",
                CountryCode  = "US",
                IsCommercial = true
            };

            _destination = new Address()
            {
                Name         = "Stratosphere Casino, Hotel & Tower",
                Address1     = "2000 S Las Vegas Blvd",
                Locality     = "Las Vegas",
                Region       = "NV",
                PostalCode   = "89104",
                CountryCode  = "US",
                IsCommercial = true
            };

            var extendedData = new ExtendedDataCollection();

            extendedData.SetValue("merchProductKey", Guid.NewGuid().ToString());
            extendedData.SetValue("merchProductVariantKey", Guid.NewGuid().ToString());
            extendedData.SetValue("merchWeight", "12");

            var lineItemCollection = new LineItemCollection()
            {
                { new ItemCacheLineItem(LineItemType.Product, "Product1", "Sku1", 1, 10, extendedData) },
                { new ItemCacheLineItem(LineItemType.Product, "Product2", "Sku2", 2, 12, extendedData) },
                { new ItemCacheLineItem(LineItemType.Product, "Product3", "Sku3", 3, 14, extendedData) },
            };

            _shipment = new Shipment(new ShipmentStatusMock(), _origin, _destination, lineItemCollection);
        }
Пример #28
0
        private LineItemCollection GetLineItemCollection(Guid itemCacheKey)
        {
            var sql = new Sql();

            sql.Select("*")
            .From <ItemCacheItemDto>()
            .Where <ItemCacheItemDto>(x => x.ContainerKey == itemCacheKey);

            var dtos = Database.Fetch <ItemCacheItemDto>(sql);

            //var lineItems = _lineItemRepository.GetByContainerId(itemCacheId);

            var factory    = new LineItemFactory();
            var collection = new LineItemCollection();

            foreach (var dto in dtos)
            {
                collection.Add(factory.BuildEntity(dto));
            }

            return(collection);
        }
Пример #29
0
        internal Invoice(IInvoiceStatus invoiceStatus, IAddress billToAddress, LineItemCollection lineItemCollection, OrderCollection orders)
        {
            Mandate.ParameterNotNull(invoiceStatus, "invoiceStatus");
            Mandate.ParameterNotNull(billToAddress, "billToAddress");
            Mandate.ParameterNotNull(lineItemCollection, "lineItemCollection");
            Mandate.ParameterNotNull(orders, "orders");

            _invoiceStatus = invoiceStatus;

            _billToName = billToAddress.Name;
            _billToAddress1 = billToAddress.Address1;
            _billToAddress2 = billToAddress.Address2;
            _billToLocality = billToAddress.Locality;
            _billToRegion = billToAddress.Region;
            _billToPostalCode = billToAddress.PostalCode;
            _billToCountryCode = billToAddress.CountryCode;
            _billToPhone = billToAddress.Phone;

            _items = lineItemCollection;
            _orders = orders;
            _invoiceDate = DateTime.Now;
        }
Пример #30
0
        //Select
        public static LineItemCollection Select(string whereClause, string orderByClause)
        {
            string        Sql     = string.Format("SELECT * from [LineItem] WHERE {0} ORDER BY {1}", whereClause, orderByClause);
            string        ConnStr = @"Server=STUDENT05;Database=prs;Trusted_Connection=True;";
            SqlConnection Conn    = new SqlConnection(ConnStr);

            Conn.Open();
            if (Conn.State != System.Data.ConnectionState.Open)
            {
                throw new ApplicationException("Connection didn't open");
            }
            SqlCommand    Cmd    = new SqlCommand(Sql, Conn);
            SqlDataReader Reader = Cmd.ExecuteReader();

            if (!Reader.HasRows)
            {
                throw new ApplicationException("Result set has no rows!");
            }
            LineItemCollection lineitems = new LineItemCollection();

            while (Reader.Read())
            {
                int id = Reader.GetInt32(Reader.GetOrdinal("id"));
                int purchaseRequestId = Reader.GetInt32(Reader.GetOrdinal("PurchaseRequestId"));
                int productId         = Reader.GetInt32(Reader.GetOrdinal("ProductID"));
                int quantity          = Reader.GetInt32(Reader.GetOrdinal("Quantity"));

                LineItem lineitem = new LineItem();
                lineitem.Id = id;
                lineitem.PurchaseRequestID = purchaseRequestId;
                lineitem.ProductID         = productId;
                lineitem.quantity          = quantity;


                lineitems.Add(lineitem);
            }
            return(lineitems);
        }
Пример #31
0
 public Invoice(XElement element)
 {
     Type = XElementHelper.ValueOrDefault<string>(element.Element("Type"));
     Contact = new Contact(element.Element("Contact"));
     Date = XElementHelper.ValueOrDefault<DateTime>(element.Element("Date"));
     DueDate = XElementHelper.ValueOrDefault<DateTime>(element.Element("DueDate"));
     InvoiceId = XElementHelper.ValueOrDefault<Guid>(element.Element("InvoiceID"));
     InvoiceNumber = XElementHelper.ValueOrDefault<string>(element.Element("InvoiceNumber"));
     BrandingThemeId = XElementHelper.ValueOrDefault<Guid>(element.Element("BrandingThemeID"));
     Url = XElementHelper.ValueOrDefault<Uri>(element.Element("Url"));
     CurrencyCode = XElementHelper.ValueOrDefault<string>(element.Element("CurrencyCode"));
     Status = XElementHelper.ValueOrDefault<string>(element.Element("Status"));
     LineAmountTypes = XElementHelper.ValueOrDefault<string>(element.Element("LineAmountTypes"));
     SubTotal = XElementHelper.ValueOrDefault<decimal>(element.Element("SubTotal"));
     TotalTax = XElementHelper.ValueOrDefault<decimal>(element.Element("TotalTax"));
     Total = XElementHelper.ValueOrDefault<decimal>(element.Element("Total"));
     AmountDue = XElementHelper.ValueOrDefault<decimal>(element.Element("AmountDue"));
     AmountPaid = XElementHelper.ValueOrDefault<decimal>(element.Element("AmountPaid"));
     AmountCredited = XElementHelper.ValueOrDefault<decimal>(element.Element("AmountCredited"));
     LineItems = new LineItemCollection(element.Element("LineItems"));
     UpdatedDateUTC = XElementHelper.ValueOrDefault<DateTime>(element.Element("UpdatedDateUTC"));
     Payments = new InvoicePaymentCollection(element.Element("Payments"));
 }
        /// <summary>
        /// Creates a update model to Sannsyn, with a list of entry/variation codes, and service name
        /// </summary>
        /// <param name="orderGroup">Order to get lineitems from</param>
        public void AddLineItemsToSannsyn(OrderGroup orderGroup)
        {
            LineItemCollection lineItems = orderGroup.OrderForms.First().LineItems;

            List <SannsynUpdateEntityModel> sannsynObjects = new List <SannsynUpdateEntityModel>();

            foreach (LineItem lineItem in lineItems)
            {
                SannsynUpdateEntityModel model = CreateSannsynObject(lineItem, orderGroup.CustomerId);
                if (model != null)
                {
                    sannsynObjects.Add(model);
                }
            }

            // Make sure we have something to index
            if (sannsynObjects.Any())
            {
                SannsynUpdateModel sannsynModel = new SannsynUpdateModel();
                sannsynModel.Service = _configuration.Service;
                sannsynModel.Updates = sannsynObjects;
                _sannsynUpdateService.SendToSannsyn(sannsynModel);
            }
        }
        private List <string> GenerateLineItemInformation(LineItemCollection lineItems, ref OrderInfo orderInfo)
        {
            orderInfo.OrderLinesHeader = "QUANTITY;UNITCODE;DESCRIPTION;AMOUNT;ITEMID;VATPERCENT";
            var items = new List <string>();

            foreach (LineItem lineItem in lineItems)
            {
                var lineInfo = string.Format("{0};{1};{2};{3};{4};{5}",
                                             (int)lineItem.Quantity,
                                             "pcs",
                                             lineItem.DisplayName,
                                             (int)(GetTotalPriceWithoutVat(lineItem, orderInfo.VatPercent) * 100),
                                             lineItem.LineItemId,
                                             (int)orderInfo.VatPercent * 100);
                items.Add(lineInfo);
                orderInfo.OrderLines.Add(lineInfo);
            }

            return(items);

            // Examples
            //<input type="hidden" name="oiRow2" value="2;pcs;ACME Band Aid;1125;99;5025" />
            //<input type="hidden" name="oiRow3" value="3;meter;ACME Black wool fabric;101;45;5000" />
        }
Пример #34
0
 public ExpenseReport()
 {
     LineItems = new LineItemCollection();
     LineItems.LineItemCostChanged += OnLineItemCostChanged;
 }
        /// <summary>
        /// Creates a collection of shipments for the current basket
        /// </summary>
        /// <returns>
        /// A collection of <see cref="IShipment"/>.
        /// </returns>
        public override IEnumerable <IShipment> PackageShipments()
        {
            // All packaged shipments will start with a shipment status of "Quoted" as these are being used for the Shipment Rate Quote
            // NOTE:  the "Packaging" status to indicate the shipment is physically being packaged/boxed up.
            var quoted = MerchelloContext.Services.ShipmentService.GetShipmentStatusByKey(Constants.DefaultKeys.ShipmentStatus.Quoted);

            // filter basket items for shippable items
            var shippableVisitor = new ShippableProductVisitor();

            LineItemCollection.Accept(shippableVisitor);

            if (!shippableVisitor.ShippableItems.Any())
            {
                return(new List <IShipment>());
            }

            // the origin address will be the default warehouse
            // For the initial version we are only exposing a single warehouse
            var warehouse = MerchelloContext.Services.WarehouseService.GetDefaultWarehouse();
            var origin    = warehouse.AsAddress();

            ////For the initial version we are only exposing a single shipment
            var shipment = new Shipment(quoted, origin, Destination)
            {
                VersionKey = VersionKey     // this is used in cache keys
            };

            // get the variants for each of the shippable line items
            var variants =
                MerchelloContext.Services.ProductVariantService.GetByKeys(
                    shippableVisitor.ShippableItems
                    .Select(x => x.ExtendedData.GetProductVariantKey())
                    .Where(x => !Guid.Empty.Equals(x))).ToArray();

            foreach (var lineItem in shippableVisitor.ShippableItems)
            {
                // We need to know what Warehouse Catalog this product is associated with for shipping and inventory
                var variant = variants.FirstOrDefault(x => x.Key.Equals(lineItem.ExtendedData.GetProductVariantKey()));
                if (variant == null)
                {
                    throw new InvalidOperationException("This packaging strategy cannot handle null ProductVariants");
                }

                if (!variant.CatalogInventories.Any())
                {
                    MultiLogHelper.Error <ShippableProductVisitor>(
                        "ProductVariant marked as shippable was not assoicated with a WarehouseCatalog.  Product was: "
                        + variant.Key.ToString() + " -  " + variant.Name,
                        new InvalidDataException());
                }
                else
                {
                    if (lineItem.ExtendedData.GetWarehouseCatalogKey().Equals(Guid.Empty))
                    {
                        // TODO this needs to be refactored to look at the entire shipment
                        // since products could be in multiple catalogs which could have
                        // opposing shippng rules and we have the destination address.
                        lineItem.ExtendedData.SetValue(
                            Constants.ExtendedDataKeys.WarehouseCatalogKey,
                            variant.CatalogInventories.First().CatalogKey.ToString());
                    }

                    shipment.Items.Add(lineItem);
                }
            }

            return(new List <IShipment> {
                shipment
            });
        }
Пример #36
0
 protected PackagingStrategyBase(LineItemCollection lineItemCollection, IAddress destination, Guid versionKey)
  : this(Core.MerchelloContext.Current, lineItemCollection, destination, versionKey)
 { }
Пример #37
0
        public void Init()
        {
            _origin = new Address()
            {
                Name = "Mindfly Web Design Studio",
                Address1 = "114 W. Magnolia St.  Suite 504",
                Locality = "Bellingham",
                Region = "WA",
                PostalCode = "98225",
                CountryCode = "US",
                IsCommercial = true
            };

            _destination = new Address()
                {
                    Name = "Stratosphere Casino, Hotel & Tower",
                    Address1 = "2000 S Las Vegas Blvd",
                    Locality = "Las Vegas",
                    Region = "NV",
                    PostalCode = "89104",
                    CountryCode = "US",
                    IsCommercial = true
                };

            var extendedData = new ExtendedDataCollection();

            extendedData.SetValue("merchProductKey", Guid.NewGuid().ToString());
            extendedData.SetValue("merchProductVariantKey", Guid.NewGuid().ToString());
            extendedData.SetValue("merchWeight", "12");

            var lineItemCollection = new LineItemCollection()
            {
                {new ItemCacheLineItem(LineItemType.Product, "Product1", "Sku1", 1, 10, extendedData)},
                {new ItemCacheLineItem(LineItemType.Product, "Product2", "Sku2", 2, 12, extendedData)},
                {new ItemCacheLineItem(LineItemType.Product, "Product3", "Sku3", 3, 14, extendedData)},
            };

            _shipment = new Shipment(new ShipmentStatusMock(), _origin, _destination, lineItemCollection);
        }
Пример #38
0
 public static IEnumerable <Models.Account.MyOrders.OrderLineItem> ToOrderItems(this LineItemCollection orderLineItems)
 {
     return(orderLineItems.Select(item => new Models.Account.MyOrders.OrderLineItem(item.Key)
     {
         Sku = item.Sku,
         DateCreated = item.CreateDate,
         Price = item.Price,
         TotalPrice = item.TotalPrice,
         Quantity = item.Quantity,
         IsShippable = item.IsShippable(),
         Name = item.Name,
     }));
 }
        internal static IOrder ToOrder(this OrderDisplay orderDisplay, IOrder destination)
        {
            if (orderDisplay.Key != Guid.Empty) destination.Key = orderDisplay.Key;
            destination.OrderNumberPrefix = orderDisplay.OrderNumberPrefix;
            destination.OrderDate = orderDisplay.OrderDate;
            destination.OrderStatus = orderDisplay.OrderStatus.ToOrderStatus();
            destination.VersionKey = orderDisplay.VersionKey;
            destination.Exported = orderDisplay.Exported;

            // TODO remove existing line items from destination not present in orderDisplay
            var items = destination.Items.Where(x => orderDisplay.Items.Any(display => display.Key == x.Key));
            var collection = new LineItemCollection();
            foreach (var item in items)
            {
                collection.Add(item);
            }

            ((Order)destination).Items = collection;

            return destination;
        }
Пример #40
0
 protected PackagingStrategyBase(LineItemCollection lineItemCollection, IAddress destination, Guid versionKey)
     : this(Core.MerchelloContext.Current, lineItemCollection, destination, versionKey)
 {
 }
Пример #41
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;
        }
Пример #42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ItemCache"/> class.
 /// </summary>
 /// <param name="entityKey">
 /// The entity key.
 /// </param>
 /// <param name="itemCacheType">
 /// The item cache type.
 /// </param>
 /// <param name="items">
 /// The items.
 /// </param>
 public ItemCache(Guid entityKey, ItemCacheType itemCacheType, LineItemCollection items)
     : this(entityKey, EnumTypeFieldConverter.ItemItemCache.GetTypeField(itemCacheType).TypeKey, items)
 {
 }
Пример #43
0
        /// <summary>
        /// Clones a shipment
        /// </summary>
        /// <param name="org">
        /// The org.
        /// </param>
        /// <returns>
        /// The <see cref="IShipment"/>.
        /// </returns>
        /// <remarks>
        /// http://issues.merchello.com/youtrack/issue/M-458
        /// </remarks>
        internal static IShipment Clone(this IShipment org)
        {
            var lineItemCollection = new LineItemCollection();

            foreach (var li in org.Items)
            {
                lineItemCollection.Add(li.AsLineItemOf<OrderLineItem>());
            }

            return new Shipment(org.ShipmentStatus, org.GetOriginAddress(), org.GetDestinationAddress(), lineItemCollection)
                               {
                                   ShipmentNumberPrefix = org.ShipmentNumberPrefix,
                                   ShipmentNumber = org.ShipmentNumber,
                                   ShippedDate = org.ShippedDate,
                                   TrackingCode = org.TrackingCode,
                                   Carrier = org.Carrier,
                                   ShipMethodKey = org.ShipMethodKey,
                                   Phone = org.Phone,
                                   Email = org.Email
                               };
        }
Пример #44
0
        public void Init()
        {
            _address = new Address()
            {
                Name = "Mindfly Web Design Studio",
                Address1 = "114 W. Magnolia St.  Suite 504",
                Locality = "Bellingham",
                Region = "WA",
                PostalCode = "98225",
                CountryCode = "US"
            };

            var extendedData = new ExtendedDataCollection();

            extendedData.SetValue("merchProductKey", Guid.NewGuid().ToString());
            extendedData.SetValue("merchProductVariantKey", Guid.NewGuid().ToString());
            extendedData.SetValue("merchWeight", "12");

            var lineItemCollection = new LineItemCollection()
            {
                {new ItemCacheLineItem(LineItemType.Product, "Product1", "Sku1", 1, 10, extendedData)},
                {new ItemCacheLineItem(LineItemType.Product, "Product2", "Sku2", 2, 12, extendedData)},
                {new ItemCacheLineItem(LineItemType.Product, "Product3", "Sku3", 3, 14, extendedData)},
            };

            _shipment = new Shipment(new ShipmentStatusMock(), _address, _address, lineItemCollection);
        }
Пример #45
0
 public Cart(DataSet tessResults)
 {
     DataTableCollection tables = tessResults.Tables;
     if (tables["Contribution"].Rows.Count > 0)
     {
         Contributions = new ContributionCollection(tables["Contribution"]);
     }
     if (tables["LineItem"].Rows.Count > 0)
     {
         LineItems = new LineItemCollection(tables["LineItem"], tables["SubLineItem"]);
     }
     if (tables["SubLineItemFee"].Rows.Count > 0)
     {
         AppliedFees = new AppliedFeeCollection(tables["SubLineItemFee"]);
     }
     if (tables["Fee"].Rows.Count > 0)
     {
         FeeCategories = new FeeCategoryCollection(tables["Fee"]);
     }
     if (tables["PriceType"].Rows.Count > 0)
     {
         PriceTypes = new CartPriceTypeCollection(tables["PriceType"]);
     }
     if (tables["Payment"].Rows.Count > 0)
     {
         Payments = new PaymentCollection(tables["Payment"]);
     }
     if (tables["PackageLineItem"].Rows.Count > 0)
     {
         PackageLineItems =
             new PackageLineItemCollection(tables["PackageLineItem"], tables["PackageSubLineItem"]);
     }
     var result = (from o in tessResults.Tables["Order"].AsEnumerable()
                   select new
                   {
                         SessionKey = o.Field<string>("sessionkey"),
                         OrderId = o.Field<int?>("order_no"),
                         AppealId = o.Field<int?>("appeal_no"),
                         SourceId = o.Field<int?>("source_no"),
                         ConstituentId = o.Field<int?>("customer_no"),
                         Solicitor = o.Field<string>("solicitor"),
                         ModeOfSaleId = o.Field<short?>("MOS"),
                         Date = o.Field<DateTime?>("order_dt"),
                         BatchId = o.Field<int?>("batch_no"),
                         Class = o.Field<short?>("class"),
                         AddressId = o.Field<int?>("address_no"),
                         HoldUntilDate = o.Field<DateTime?>("hold_until_dt"),
                         TransactionId = o.Field<int?>("transaction_no"),
                         HoldAtBoxOffice = o.Field<string>("habo_ind"),
                         Notes = o.Field<string>("notes"),
                         BusinessUnit = o.Field<short?>("bu"),
                         ShippingMethodId = o.Field<int?>("shipping_method"),
                         ShippingMethodName = o.Field<string>("shipping_method_desc"),
                         OrderTotal = o.Field<decimal?>("order_total"),
                         OrderValue = o.Field<decimal?>("order_value"),
                         Notes1 = o.Field<string>("notes1"),
                         DbStatus = o.Field<short?>("db_status"),
                         AmountToCharge = o.Field<decimal?>("amt_to_charge"),
                         FirstSeatAddedTime = o.Field<DateTime?>("first_seat_added_dt"),
                         AmountPaidToDate = o.Field<decimal?>("amt_paid_to_dt"),
                         AmountPaidNow = o.Field<decimal?>("amt_paid_now"),
                         BalanceToCharge = o.Field<decimal?>("balance_to_charge"),
                         Subtotal = o.Field<decimal?>("SubTotal"),
                         HandlingCharges = o.Field<decimal?>("HandlingCharges"),
                         Custom1 = o.Field<string>("custom_1"),
                         Custom2 = o.Field<string>("custom_2"),
                         Custom3 = o.Field<string>("custom_3"),
                         Custom4 = o.Field<string>("custom_4"),
                         Custom5 = o.Field<string>("custom_5"),
                         Custom6 = o.Field<string>("custom_6"),
                         Custom7 = o.Field<string>("custom_7"),
                         Custom8 = o.Field<string>("custom_8"),
                         Custom9 = o.Field<string>("custom_9"),
                         Custom0 = o.Field<string>("custom_0")
                   }).Single();
     SessionKey = result.SessionKey;
     OrderId = result.OrderId;
     AppealId = result.AppealId;
     SourceId = result.SourceId;
     ConstituentId = result.ConstituentId;
     Solicitor = result.Solicitor;
     ModeOfSaleId = result.ModeOfSaleId;
     Date = result.Date;
     BatchId = result.BatchId;
     Class = result.Class;
     AddressId = result.AddressId;
     HoldUntilDate = result.HoldUntilDate;
     TransactionId = result.TransactionId;
     HoldAtBoxOffice = ToBool(result.HoldAtBoxOffice);
     Notes = result.Notes;
     BusinessUnit = result.BusinessUnit;
     ShippingMethodId = result.ShippingMethodId;
     ShippingMethodName = result.ShippingMethodName;
     OrderTotal = result.OrderTotal;
     OrderValue = result.OrderValue;
     Notes1 = result.Notes1;
     DbStatus = result.DbStatus;
     AmountToCharge = result.AmountToCharge;
     FirstSeatAddedTime = result.FirstSeatAddedTime;
     AmountPaidToDate = result.AmountPaidToDate;
     AmountPaidNow = result.AmountPaidNow;
     BalanceToCharge = result.BalanceToCharge;
     Subtotal = result.Subtotal;
     HandlingCharges = result.HandlingCharges;
     Custom0 = result.Custom0;
     Custom1 = result.Custom1;
     Custom2 = result.Custom2;
     Custom3 = result.Custom3;
     Custom4 = result.Custom4;
     Custom5 = result.Custom5;
     Custom6 = result.Custom6;
     Custom7 = result.Custom7;
     Custom8 = result.Custom8;
     Custom9 = result.Custom9;
 }
        /// <summary>
        /// Adds a <see cref="LineItemCollection"/> to the <see cref="ExtendedDataCollection"/>
        /// </summary>
        /// <param name="extendedData">
        /// The extended Data.
        /// </param>
        /// <param name="lineItemCollection">
        /// The line Item Collection.
        /// </param>
        public static void AddLineItemCollection(this ExtendedDataCollection extendedData, LineItemCollection lineItemCollection)
        {
            using (var sw = new StringWriter())
            {
                var settings = new XmlWriterSettings()
                {
                    OmitXmlDeclaration = true
                };

                using (var writer = XmlWriter.Create(sw, settings))
                {
                    writer.WriteStartDocument();
                    writer.WriteStartElement(Constants.ExtendedDataKeys.LineItemCollection);

                    foreach (var lineItem in lineItemCollection)
                    {
                        ////writer.WriteStartElement(Constants);
                        writer.WriteRaw(((LineItemBase)lineItem).SerializeToXml());
                    }

                    writer.WriteEndElement(); // ExtendedData
                    writer.WriteEndDocument();
                }
                extendedData.SetValue(Constants.ExtendedDataKeys.LineItemCollection, sw.ToString());
            }
        }
Пример #47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InvoiceFactory"/> class.
 /// </summary>
 /// <param name="lineItemCollection">
 /// The line item collection.
 /// </param>
 /// <param name="orderCollection">
 /// The order collection.
 /// </param>
 public InvoiceFactory(LineItemCollection lineItemCollection, OrderCollection orderCollection)
 {
     _lineItemCollection = lineItemCollection;
     _orderCollection    = orderCollection;
 }
Пример #48
0
 public OrderFactory(LineItemCollection lineItemCollection)
 {
     _lineItemCollection = lineItemCollection;
 }